是否可以将字段(而不是其内容)存储为 FileMaker 中的变量?

问题描述 投票:0回答:1

我开始清理 FileMaker 数据库中的一些旧代码。有人有以下脚本,允许用户将文件上传到容器字段。脚本根据脚本参数确定将文件存储在哪个字段中。

Set Error Capture [On]
Allow User Abort [Off]

Set Variable [$ScriptParameter; Value: Get (ScriptParameter)]

If [$ScriptParameter = "Clean"]
    Insert File [Insert; Display content; Never compress; Target:Inspections::cert_Clean]
Else If [$ScriptParameter = "C of C"]
    Insert File [Insert; Display content; Never compress; Target:Inspections::cert_C of C]
Else If [$ScriptParameter = "Hardness"]
    Insert File [Insert; Display content; Never compress; Target:Inspections::cert_Hardness]
...
.
.
End If

它或多或少是一个查找表。我想从查找表中提取实际的

Insert File
函数,并仅使用存储目标字段的变量。然后让
Insert File
从变量中获取其目标。是否可以使用
Set Variable
存储字段本身,而不是其内容?

variable-assignment filemaker lookup-tables
1个回答
0
投票

脚本参数始终是,而不是字段引用

另一件事是

Insert File
脚本步骤将让您动态指定目标字段;您必须将目标字段“烘焙”到步骤中。

不过,您可以做的是首先将文件插入到变量中,然后使用

Set Field By Name

 脚本步骤将插入的文件放置在脚本参数确定的目标字段中。但是,您需要将目标字段的 
name (作为文本)作为脚本参数传递 - 例如,设置参数:

GetFieldName ( Target:Inspections::cert_Clean )
对于第一个字段,依此类推。那么你的脚本就可以简单地完成:

Insert File [ $insertedFile ] Set Field By Name [ Get ( ScriptParameter ); $insertedFile ]


附注这一步:

Set Variable [$ScriptParameter; Value: Get (ScriptParameter)]
除了浪费 CPU 周期和内存之外,没有任何作用。脚本参数本身已经是一个变量;可以直接参考。

© www.soinside.com 2019 - 2024. All rights reserved.