Jump to content

This topic is 7349 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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 ?

Posted

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 ?

Posted

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 ?

Posted

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" ) ]

Posted

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" ) ]

Posted

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" ) ]

Posted

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 ;-)

Posted

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 ;-)

Posted

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 ;-)

Posted

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[].

Posted

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[].

Posted

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[].

Posted

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 ?

Posted

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 ?

Posted

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 ?

Posted

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.

Posted

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.

Posted

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.

This topic is 7349 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.