Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
To load variables from external file the below script works and i can see all the variable in variable overview window after the reload.
VariablesTable:
LOAD VariableName, VariableValue
FROM
[QVDStore\VariablesTable.QVD]
(qvd);
for i=0 to noofrows('VariablesTable')-1
LET var_name= peek('VariableName',i,'VariablesTable');
LET $(var_name) = peek('VariableValue',i,'VariablesTable');
next i
I cannot understand how the above 2 LET statements can able to create a variable and load value into the variable?
-The confusing part is, how the variable with DSE $(var_name) is loading value into the variable?
Try using the debugger to step through the execution of the script step by step. You can follow what happens that way and see the values of the variables at each step.
The first LET statement gets the name of the variable you want to create and stores it in the variable var_name. Then the next LET statement uses that var_name variable to create a variable with then name of the variable that was retrieved from the table in the first LET statement. That's why the dollar expansion is used in the second LET statement.
Thanks for the reply Gysbert.
First of all, may be i never saw statement having LET with DSE. So I am still confused, about how it works.
-The 2nd LET statement is using the already existing variable(var_name, containing 1st value in field VariableName).
I think, in general DSE is only to evaluate the content and return the result, but how the $(var_name) is loaded with Value(VariableValue) to the existing variable var_name ??
Try using the debugger to step through the execution of the script step by step. You can follow what happens that way and see the values of the variables at each step.
Enable log file generation and have a look at the resulting log file. You will see DSE in action.
BTW Dollar-sign expansion in this case is not about content evaluation, it's all bout text substitution. Before evaluating every individual statement and executing it, the script engine will pre-process a statement and replace all occurences of things that look like $(...) by the output of the pseudo-expression between the parentheses. This works recursively (you can embed dollar-sign expansions within DSE's). When all expansions have been performed, the resulting statement text will be fed to the script engine for proper execution. That last statement format is what is being printed in the log file.
Peter
Thanks Peter for the clear explanation.
-I understood how it works using debugger.
Yes, the 2nd LET statement is actually reading $(var_name) as vVar which is a value of var_name(created in 1st LET statement).