Focal Point
[SOLVED] Dynamically named variables.

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/8447042976

November 06, 2015, 04:36 PM
Michael2001
[SOLVED] Dynamically named variables.
Is there a way to create a variable with the name of the variable contained in a second variable?

For example
-SET &VARNAME='DBASENAME';
-SET &'&VARNAME'='ThisName';

-? & would get the following
&VARNAME = DBASENAME
&DBASENAME = ThisName

This message has been edited. Last edited by: Michael2001,


WebFOCUS 8.1.04
Data Migrator
Excel, PDF, HTML, Active Technologies
Windows 7
November 06, 2015, 05:29 PM
CoolGuy
Michael2001,

The following works, but there is an issue with WF auto-prompting for the variable unless you first -DEFAULTH it up top:

-SET &ECHO = 'ALL';

-DEFAULTH &DBASENAME = '';

-SET &VARNAME = 'DBASENAME';
-SET &VARNAME2 = '&' | '&VARNAME.EVAL';
-SET &VARNAME2.EVAL = 'Tadaa!';
-TYPE &VARNAME &VARNAME2 &DBASENAME



8.2.02M (production), 8.2.02M (test), Windows 10, all outputs.
November 08, 2015, 09:40 AM
Danny-SRL
Try this:
  
-SET &VAR=DB;
-SET &.&VAR=MICHAEL;
-TYPE &VAR
-TYPE &.&VAR



Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

November 09, 2015, 04:28 AM
Dave
As . can be used to concatenate names to a single parameter:

-SET &IDX = 0;
-LOOP
-SET &IDX = &IDX + 1;
-SET &PARAM.&IDX = &IDX * 5;
-IF &IDX LT 5 THEN GOTO LOOP;

-TYPE &PARAM1
-TYPE &PARAM2
-TYPE &PARAM3
-TYPE &PARAM4
-TYPE &PARAM5



_____________________
WF: 8.0.0.9 > going 8.2.0.5
November 09, 2015, 09:14 AM
Michael2001
That worked thanks.


WebFOCUS 8.1.04
Data Migrator
Excel, PDF, HTML, Active Technologies
Windows 7