TeleFlow Forums
http://teleflow.org/phpbb/

Dynamically creating numbered variable names
http://teleflow.org/phpbb/viewtopic.php?f=10&t=486
Page 1 of 1

Author:  fesquivel [ Mon Dec 17, 2007 3:19 pm ]
Post subject:  Dynamically creating numbered variable names

I'm developing an application that dynamically loads several configuration parameters in order to evaluate incoming requests.

I need to program a simple cycle that uses an Index (@IDX, numeric). In each iteration I need to use an XML Fetch to obtain the next info:

Handle: --
Node: CONFIG->PROD@IDX
To: @GBL_PROD@IDX

In the node the interpreter will substitute the @IDX value and it will try to get CONFIG->PROD1; this works just fine.

But, how can I use the same @IDX value in the target variable specified in To:, so as to dynamically create the variable @GBL_PROD1 with the value of CONFIG->PROD1?

The idea is to be able to create up to <n> variables this way.

Thanks in advance.

Author:  Chris [ Tue Dec 18, 2007 12:08 pm ]
Post subject: 

Dynamically creating variables isn't possible in TeleFlow (or, if you find a place you CAN do it, it would be an unexpected side-effect of how a step works), and even if you could, no steps could reference your variables, because you can't reference a variable name using a variable or variables.

The trick I can recommend (that could provide something close to what you are looking for, I believe) is to create what is effectively a pseudo-array(not a true array, as TeleFlow doesn't have arrays) using a single variable. Each time you fetch a result, append it to the existing variable, but with a comma or other delimiter character, such as a tilde(~), between each result value.

Then, whenever you wish to reference one of the elements of your array, follow the instructions for arrays in the TeleFlow Help:
1 - Develop Applications with TeleFlow Designer >> Variables >> Arrays

Author:  fesquivel [ Tue Dec 18, 2007 4:00 pm ]
Post subject:  Thanks!

Geez! Nice aproach :D I'll give it a try, thanks.

Page 1 of 1 All times are UTC - 8 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/