Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
peter_turner
Partner - Specialist
Partner - Specialist

Setting a variable from file

Hello All,

I need to figure out how to load some defaults into my variables from a file.

The idea is i have a Defaults.ini file which is tab delimited.
The file has the variable and then the expression i want to store into it.
Some expressions would be just text but others might be functions

So far i have a load of the data

Directory;
LOAD variable,
expression
FROM
Defaults.ini
(txt, codepage is 1252, embedded labels, delimiter is '\t', msq);

But now i need to assign the variable with the expression, any ideas?

Thanks,
Peter.

1 Solution

Accepted Solutions
Not applicable

Hi Peter,

Here you are a possible solution.

I hope this help you.

Best regards.

View solution in original post

7 Replies
Not applicable

Hi Peter,

Here you are a possible solution.

I hope this help you.

Best regards.

peter_turner
Partner - Specialist
Partner - Specialist
Author

Hello,

Thank you for your fast reply.
i would like to replace the var1 with a 'peek' for the variable name instead, but i'm having trouble with the command.

let var1 = peek('Expression', 0, Tvariable ); is OK

I want to change the command to:
let peek('Variable', 0, Tvariable )=peek( 'Expression', 0, Tvariable ); = Script line error.

I have also tryed using the evaluate() function, and Let or Set.

Thanks,
Peter.

Not applicable

Hi Peter,

As far as I know, that is impossible, you can't create / define a variable as result of a expression.

Sorry.

Best regards.

peter_turner
Partner - Specialist
Partner - Specialist
Author

Hi Miguel,

I figured a solution out.

I made a new variable called 'var_temp' which will hold the variables name first, then use this to assign the value

let var_temp = peek('Variable', 0, Tvariable );
let $(var_temp) = peek('Expression', 0, Tvariable );

Next for me is to make a loop to read from row 0 to the EOF 🙂

Thanks,
Peter.

Not applicable

Hi Peter,

Smart solution. You've got !!

Best regards.

jbeierschmitt
Contributor III
Contributor III

I successfully tested this script to support maintaining change control between our development, quality and production environments where an external reference provides the NAS folder reference.

However, for some reason when I attempt to use the exact same script after a binary load it does not appear to function correctly.

Any ideas or suggestions?

Thanks

Jim

jbeierschmitt
Contributor III
Contributor III

User error - the table I used to create the variables did not get dropped so it was part of the binary load.

Once I dropped that table the script worked.