![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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. |
#3
| |||
| |||
|
|
"MaximalVariance" <StephenTGallagher (AT) gmail (DOT) com> schreef in bericht news:1181223683.766613.23930 (AT) q69g2000hsb (DOT) googlegroups.com... 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. Presume you have at least version 7, but better 8.5. It has a nice function FieldNames(fileName;layoutName)Create a layout with all fields on it (easy enough) <AllFields Goto that layout create a calc Fieldnames ( Get ( Filename) ; "AllFields" ) this will return a return delimited list with all FieldNames. Easy enough to store and reuse, looping through the list. Keep well, Ursus |
#4
| |||
| |||
|
|
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. |
#5
| |||
| |||
|
|
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 |
#6
| |||
| |||
|
|
Helpful Harry 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. But suppose you had all your target fields on a special layout. Go to the first field and make note of what it is (using Get(ActiveFieldName) so you know where you began your journey). Then loop through all fields on the layout (using Go To Next Field) until you come back to the starting point. At each stop along the way you can set the field with something like: Set Field [no target field specified; GetField ("RelatedTable::" & Get(ActiveFieldName)) ] Note that "Get(ActiveFieldName)" was "Status(CurrentFieldName)" in version 6 and maybe 5.5. -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Howard Schlossberg FM Professional Solutions, Inc. Los Angeles FileMaker 8 Certified Developer Member, FileMaker Business Alliance |
#7
| |||
| |||
|
|
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. |
#8
| |||
| |||
|
|
Helpful Harry 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. But suppose you had all your target fields on a special layout. Go to the first field and make note of what it is (using Get(ActiveFieldName) so you know where you began your journey). Then loop through all fields on the layout (using Go To Next Field) until you come back to the starting point. At each stop along the way you can set the field with something like: Set Field [no target field specified; GetField ("RelatedTable::" & Get(ActiveFieldName)) ] Note that "Get(ActiveFieldName)" was "Status(CurrentFieldName)" in version 6 and maybe 5.5. |
)
#9
| |||
| |||
|
|
If this is the case then it is the answer to the original question, although it's still a long winded approach that may be better off being changed to use a separate table with 500 records rather than 500 fields. |
#10
| |||
| |||
|
|
Helpful Harry wrote: If this is the case then it is the answer to the original question, although it's still a long winded approach that may be better off being changed to use a separate table with 500 records rather than 500 fields. I'm not sure I understand what is long-winded about it. I can write this script in about seven steps. I challenge you to do it in fewer. Go to Next Field Set Variable [$Start; Get(ActiveFieldName) ] Loop Set Field [no target field specified; GetField ("RelatedTable::" & Get(ActiveFieldName)) ] Go to Next Field Exit Loop If [ $Start = Get(ActiveFieldName) ] End Loop |
)![]() |
| Thread Tools | |
| Display Modes | |
| |