![]() | |
![]() |
| | Thread Tools | Display Modes |
#11
| |||
| |||
|
|
Hello-- I have a situation where I want the same script executed iteratively over all fields (+500) in one particular table. (These are all molecular structures in the same pathway and they do all belong in one table). I am comparing the values in each field to related values in another table, where the two tables are related by person ID. If there is any difference between these two tables, I would like the value of a third table to store a message like 'error' or 'match' for each of the 500 variables. This part is all easy enough, my only dilemma is in not wanting to hard code the variable names multiple times into each of the scripts for each comparison. So, to summarize, has anyone succesfully passed the field names in a databases defintion as script parameters? Something pseudo code-ish to a "for each field y in table x...{logic here}" where i can dynamically populate the "y's" in the previous line. thanks for any thoughts. -sg |
#12
| |||
| |||
|
|
Hello-- I have a situation where I want the same script executed iteratively over all fields (+500) in one particular table. (These are all molecular structures in the same pathway and they do all belong in one table). I am comparing the values in each field to related values in another table, where the two tables are related by person ID. If there is any difference between these two tables, I would like the value of a third table to store a message like 'error' or 'match' for each of the 500 variables. This part is all easy enough, my only dilemma is in not wanting to hard code the variable names multiple times into each of the scripts for each comparison. So, to summarize, has anyone succesfully passed the field names in a databases defintion as script parameters? Something pseudo code-ish to a "for each field y in table x...{logic here}" where i can dynamically populate the "y's" in the previous line. thanks for any thoughts. -sg |
#13
| |||
| |||
|
|
In article <46698c92$0$95239$dbd49... (AT) news (DOT) wanadoo.nl>, "Ursus" ursus.k... (AT) wanadoo (DOT) nl> wrote: The FieldNames function has been there since at least FileMaker 4, but unfortunately I can't see it being of any use for this problem. Although that will let you obtain a list of the names of the fields, you can't actually use those names within other functions in place of a field - you can't, for example, use Set Field [VariableField, "5"] where VariableField can take on any of the real field names that you want to set the value of. This means you can't set the value of all five fields called: Field_1, Field_2, Field_3, Field_4, Field_5 by using a loop like Set Parameter [Variable, 1] Loop Set Field ["Field_" & Variable, "My Value"] Set Parameter [Variable, Variable + 1] Exit Loop If [Variable = 6] End Loop You instead have to hardcode the Set Field command five times with the actual field names. ie. Set Field [Field_1, "My Value"] Set Field [Field_2, "My Value"] Set Field [Field_3, "My Value"] Set Field [Field_4, "My Value"] Set Field [Field_5, "My Value"] Harry, the OP was talking about script parameters. With 8 you can set a variable and use this Set Variable <$MyVariable ; MyValue Perform Scipt <Somescript ; $MyVariable Now you see how the variable can hold any value from the list with fieldnmames and parse it to a second script as scriptparameter. Yes variables are useful, but they were also wanting to use those parameters within other functions in place of field names to access the field's data, which as far as I can work out (and may well be wrong of course) is not possible, eg. Set Field [$MyVariable, "My Value"] or If ($MyVariable = "My Value", "Yes", "No") where $MyVariable contains the name of a field and you want to set or retrieve the actual data value of that field. For example, if $MyVariable contains "MyField_1" using the above Set Field command will not set the data of MyField_1 to "My Value". Or in the second example the If statement will test the contents of $MyVariable, not the contents of the field MyField_1. Both are likely produces a "Field name expected" error when trying to exit the script / calculation. The way around this may be to use the variable (or a temporary field) to store each fields value as you loop through copying the data values from each field in sequence, but it would be a long-winded process for 500 fields. I think the best answer is more likely to be to separate those fields into 500 records in another table. Helpful Harry Hopefully helping harassed humans happily handle handiwork hardships ;o) |
#14
| |||
| |||
|
|
The FieldNames function has been there since at least FileMaker 4, but unfortunately I can't see it being of any use for this problem. Although that will let you obtain a list of the names of the fields, you can't actually use those names within other functions in place of a field - you can't, for example, use Set Field [VariableField, "5"] where VariableField can take on any of the real field names that you want to set the value of. This means you can't set the value of all five fields called: Field_1, Field_2, Field_3, Field_4, Field_5 by using a loop like Set Parameter [Variable, 1] Loop Set Field ["Field_" & Variable, "My Value"] Set Parameter [Variable, Variable + 1] Exit Loop If [Variable = 6] End Loop You instead have to hardcode the Set Field command five times with the actual field names. ie. Set Field [Field_1, "My Value"] Set Field [Field_2, "My Value"] Set Field [Field_3, "My Value"] Set Field [Field_4, "My Value"] Set Field [Field_5, "My Value"] |
#15
| |||
| |||
|
|
On Jun 8, 5:45 pm, Helpful Harry <helpful_ha... (AT) nom (DOT) de.plume.com wrote: In article <46698c92$0$95239$dbd49... (AT) news (DOT) wanadoo.nl>, "Ursus" ursus.k... (AT) wanadoo (DOT) nl> wrote: The FieldNames function has been there since at least FileMaker 4, but unfortunately I can't see it being of any use for this problem. Although that will let you obtain a list of the names of the fields, you can't actually use those names within other functions in place of a field - you can't, for example, use Set Field [VariableField, "5"] where VariableField can take on any of the real field names that you want to set the value of. This means you can't set the value of all five fields called: Field_1, Field_2, Field_3, Field_4, Field_5 by using a loop like Set Parameter [Variable, 1] Loop Set Field ["Field_" & Variable, "My Value"] Set Parameter [Variable, Variable + 1] Exit Loop If [Variable = 6] End Loop You instead have to hardcode the Set Field command five times with the actual field names. ie. Set Field [Field_1, "My Value"] Set Field [Field_2, "My Value"] Set Field [Field_3, "My Value"] Set Field [Field_4, "My Value"] Set Field [Field_5, "My Value"] Harry, the OP was talking about script parameters. With 8 you can set a variable and use this Set Variable <$MyVariable ; MyValue Perform Scipt <Somescript ; $MyVariable Now you see how the variable can hold any value from the list with fieldnmames and parse it to a second script as scriptparameter. Yes variables are useful, but they were also wanting to use those parameters within other functions in place of field names to access the field's data, which as far as I can work out (and may well be wrong of course) is not possible, eg. Set Field [$MyVariable, "My Value"] or If ($MyVariable = "My Value", "Yes", "No") where $MyVariable contains the name of a field and you want to set or retrieve the actual data value of that field. For example, if $MyVariable contains "MyField_1" using the above Set Field command will not set the data of MyField_1 to "My Value". Or in the second example the If statement will test the contents of $MyVariable, not the contents of the field MyField_1. Both are likely produces a "Field name expected" error when trying to exit the script / calculation. The way around this may be to use the variable (or a temporary field) to store each fields value as you loop through copying the data values from each field in sequence, but it would be a long-winded process for 500 fields. I think the best answer is more likely to be to separate those fields into 500 records in another table. Variables are not limited in the way you think they are. In the two examples above, the first wouldn't work, but that's a limitation of Set Field, not variables. And the second would work fine, based on the value of the field at the time you set the variable. The field itself is not evaluated when the variable is, but rather the contents of the variable are set to the fields contents. I've found variables to be very robust, except for the 'repeating' feature, which is kind of bogus. |
![]() |
| Thread Tools | |
| Display Modes | |
| |