March 15, 200520 yr Author In a DB, i've numerous fields and relationships, all named at the end with a "number". I use scripts with getparameters and IF/END IF structures. The problem is : it creates large script, with repetiting structures. My question : would it be possible to use a calc with the LET function and a variable to replace all thoses IF/END IF structures (or CASE structure within a calc field) ? Example : if getparameters = 1 then set field RELATION1::FIELD1="aaaaaaa" if getparameters = 2 then set field RELATION2::FIELD2="bbbbbbb" if getparameters = 3 then set field RELATION3::FIELD3="ccccccc" if getparameters = 4 then set field RELATION4::FIELD4="ddddddd I "feel" that I can do something with LET and/or EVALUATE, but I really have problems to use this rather complex function... Can you help me ?
March 15, 200520 yr In a DB, i've numerous fields and relationships, all named at the end with a "number". I use scripts with getparameters and IF/END IF structures. The problem is : it creates large script, with repetiting structures. My question : would it be possible to use a calc with the LET function and a variable to replace all thoses IF/END IF structures (or CASE structure within a calc field) ? Example : if getparameters = 1 then set field RELATION1::FIELD1="aaaaaaa" if getparameters = 2 then set field RELATION2::FIELD2="bbbbbbb" if getparameters = 3 then set field RELATION3::FIELD3="ccccccc" if getparameters = 4 then set field RELATION4::FIELD4="ddddddd I "feel" that I can do something with LET and/or EVALUATE, but I really have problems to use this rather complex function... Can you help me ?
March 15, 200520 yr Author In a DB, i've numerous fields and relationships, all named at the end with a "number". I use scripts with getparameters and IF/END IF structures. The problem is : it creates large script, with repetiting structures. My question : would it be possible to use a calc with the LET function and a variable to replace all thoses IF/END IF structures (or CASE structure within a calc field) ? Example : if getparameters = 1 then set field RELATION1::FIELD1="aaaaaaa" if getparameters = 2 then set field RELATION2::FIELD2="bbbbbbb" if getparameters = 3 then set field RELATION3::FIELD3="ccccccc" if getparameters = 4 then set field RELATION4::FIELD4="ddddddd I "feel" that I can do something with LET and/or EVALUATE, but I really have problems to use this rather complex function... Can you help me ?
March 15, 200520 yr You could do a single script step like: Set Field [ RELATION1::FIELD1 ; Case ( getparameters = 1 ; "aaaaaaa" ; getparameters = 2 ; "bbbbbbb" ; getparameters = 3 ; "ccccccc" ; getparameters = 4 ; "ddddddd" ) ] or: Set Field [ RELATION1::FIELD1 ; Choose ( getparameters - 1 ; "aaaaaaa" ; "bbbbbbb" ; "ccccccc" ; "ddddddd" ) ]
March 15, 200520 yr You could do a single script step like: Set Field [ RELATION1::FIELD1 ; Case ( getparameters = 1 ; "aaaaaaa" ; getparameters = 2 ; "bbbbbbb" ; getparameters = 3 ; "ccccccc" ; getparameters = 4 ; "ddddddd" ) ] or: Set Field [ RELATION1::FIELD1 ; Choose ( getparameters - 1 ; "aaaaaaa" ; "bbbbbbb" ; "ccccccc" ; "ddddddd" ) ]
March 15, 200520 yr You could do a single script step like: Set Field [ RELATION1::FIELD1 ; Case ( getparameters = 1 ; "aaaaaaa" ; getparameters = 2 ; "bbbbbbb" ; getparameters = 3 ; "ccccccc" ; getparameters = 4 ; "ddddddd" ) ] or: Set Field [ RELATION1::FIELD1 ; Choose ( getparameters - 1 ; "aaaaaaa" ; "bbbbbbb" ; "ccccccc" ; "ddddddd" ) ]
March 15, 200520 yr Author Yes of course. But the point is to use the getparameter as a variable to address (identify) different fields and relationships. fieldX relationx::fieldX where X is the getparameter. This is the tricky part ;-)
March 15, 200520 yr Author Yes of course. But the point is to use the getparameter as a variable to address (identify) different fields and relationships. fieldX relationx::fieldX where X is the getparameter. This is the tricky part ;-)
March 15, 200520 yr Author Yes of course. But the point is to use the getparameter as a variable to address (identify) different fields and relationships. fieldX relationx::fieldX where X is the getparameter. This is the tricky part ;-)
March 15, 200520 yr Sorry - didn't notice you have changed fields. Then the only thing you can do is use Else If to trim it down a bit. There is no way to dynamically specify which field to Set[].
March 15, 200520 yr Sorry - didn't notice you have changed fields. Then the only thing you can do is use Else If to trim it down a bit. There is no way to dynamically specify which field to Set[].
March 15, 200520 yr Sorry - didn't notice you have changed fields. Then the only thing you can do is use Else If to trim it down a bit. There is no way to dynamically specify which field to Set[].
March 16, 200520 yr Author Sorry Comment, english is not my native language so it's a little bit difficult to express myself. I know that within a script you can not dynamically specify which field to Set[] In fact, i would like to use it into the "calculated result" part of a Set Field[] In this cas, i think with LET and EVALUATE you can dynamically "name" a field. What do u think about it ?
March 16, 200520 yr Author Sorry Comment, english is not my native language so it's a little bit difficult to express myself. I know that within a script you can not dynamically specify which field to Set[] In fact, i would like to use it into the "calculated result" part of a Set Field[] In this cas, i think with LET and EVALUATE you can dynamically "name" a field. What do u think about it ?
March 16, 200520 yr Author Sorry Comment, english is not my native language so it's a little bit difficult to express myself. I know that within a script you can not dynamically specify which field to Set[] In fact, i would like to use it into the "calculated result" part of a Set Field[] In this cas, i think with LET and EVALUATE you can dynamically "name" a field. What do u think about it ?
March 16, 200520 yr Set Field[] has two parts: 1. WHICH field; 2. WHAT to put in this field. The first part cannot be specified by a calculation. The calculation only affects the second part. Let() and Evaluate() are functions that you can use in the calculation, but they cannot change the LOCATION of the calculation's result. Therefore, your example of: If TRUE, Set Field X to something ; if FALSE, Set Field Y to something is impossible as a calculation. It must be done by script steps. You can only select which field is REFERENCED by a calculation. For example, if you have 2 fields named Field1 and Field2, you can write a calculation like: GetField("Field" & Get(ScriptParameter) ) This will return the CONTENT of Field1 when ScriptParameter="1", the CONTENT of Field2 when ScriptParameter="2", and an error otherwise.
March 16, 200520 yr Set Field[] has two parts: 1. WHICH field; 2. WHAT to put in this field. The first part cannot be specified by a calculation. The calculation only affects the second part. Let() and Evaluate() are functions that you can use in the calculation, but they cannot change the LOCATION of the calculation's result. Therefore, your example of: If TRUE, Set Field X to something ; if FALSE, Set Field Y to something is impossible as a calculation. It must be done by script steps. You can only select which field is REFERENCED by a calculation. For example, if you have 2 fields named Field1 and Field2, you can write a calculation like: GetField("Field" & Get(ScriptParameter) ) This will return the CONTENT of Field1 when ScriptParameter="1", the CONTENT of Field2 when ScriptParameter="2", and an error otherwise.
March 16, 200520 yr Set Field[] has two parts: 1. WHICH field; 2. WHAT to put in this field. The first part cannot be specified by a calculation. The calculation only affects the second part. Let() and Evaluate() are functions that you can use in the calculation, but they cannot change the LOCATION of the calculation's result. Therefore, your example of: If TRUE, Set Field X to something ; if FALSE, Set Field Y to something is impossible as a calculation. It must be done by script steps. You can only select which field is REFERENCED by a calculation. For example, if you have 2 fields named Field1 and Field2, you can write a calculation like: GetField("Field" & Get(ScriptParameter) ) This will return the CONTENT of Field1 when ScriptParameter="1", the CONTENT of Field2 when ScriptParameter="2", and an error otherwise.
Create an account or sign in to comment