Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

variables evalution confusion?

for i=0 to noofrows('VariablesTable')-1

  LET var_name= peek('VariableName',i,'VariablesTable');

  LET $(var_name) = peek('VariableValue',i,'VariablesTable');

  TRACE Load Variable: $(var_name) = $($(var_name)); 

how it can evaluated?

8 Replies
tamilarasu
Champion
Champion

Hi Josna,

Use debug option to see the evaluation.

Capture.PNG

Not applicable
Author

Hi jasna,

you'll need to expand 'i' when used in the peek

$(i)

hope that helps

Joe

Mark_Little
Luminary
Luminary

Hi,

I am not sure what you are trying to achieve?

I wouldn't approach like approach the above maybe something like

  SET var_name= peek('VariableName',i,'VariablesTable');

  LET var_Value = peek('VariableValue',i,'VariablesTable');

  TRACE Load Variable: var_name = $(var_name);

Some more information would be useful.

Mark

Not applicable
Author

Dear Mark i am not trying to achieve in my application just i saw this function in demo app i cannot underdand this one so for more information purpose i post that

Thanks and Regards

Josh

avinashelite

Hi josna,

As Nagaraj mentioned you can make use of the debug window to see the what values getting set in the backend.

or you can use the TRACE function to popup the values during the reload

I feel your getting confused in the $ sign expansion ? $ represent the current value of the variable

Mark_Little
Luminary
Luminary

HI Josh,

Not sure where you have seen it,

But basically it looks like the are loading a a number of formulas and then the results and the bringing up a trace to see if they match

for example

RowVariable NameVariable value
12+24
23+36

So the we would have

  LET var_name= 2+2;

  LET $(var_name) = 4;

Trace would return 4 = 4

Mark

Peter_Cammaert
Partner - Champion III
Partner - Champion III

This is a very simple double-dollar expansion.

The idea is to have a list of variables in an external data file, and their values. You can store this in an Excel file or a QVD. It works as an external configuration file.

What happens is that the FOR loop first reads a variable name, and then assigns a value to that variable name. all without knowing the name of the variable beforehand. For example, my Excel may contain the following:

VariableName    VariableValue

vMySetting1     5

The first Let stores 'vMySetting' in variable var_name.

The second LET expands to:

LET vMySetting1 = peek(...

and assigns a value to the variable I just came to know.

Very powerful technique. Gives you the freedom to configure your document in the wildest manner, all without visiting the load script. Ever.

Peter

engishfaque
Specialist III
Specialist III

Dear Josna,

We use this technique mostly making dynamic variables,

Step 1:    for i=0 to noofrows('VariablesTable')-1

Here you're using loop from value 0 to Last number of rows - 1

Step 2:    LET var_name= peek('VariableName',i,'VariablesTable');

Here you're evaluating and assigning variable name to "var_name"

Step 3:    LET var_Value = peek('VariableValue',i,'VariablesTable');

Here you're evaluating and assigning variable value to "var_Value"

Step 4:    TRACE Load Variable: var_name = $(var_name);

Here you're only printing variable using Trace keyword.

For more clarification, kindly find attached document and screenshot.

Kind regards,

Ishfaque Ahmed