Variable substitution in Job Control ?

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
dcoueron
Participant
Posts: 19
Joined: Wed Sep 26, 2007 8:45 am
Location: Paris

Variable substitution in Job Control ?

Post by dcoueron »

Is there any way to substitute a variable name with its value in a job control ? (Some kind of eval function)

Example :
varA = "test"
varB = "varA"
I need to get varC = "test" by calling something like varC = eval(varB)
Damien
arvind_ds
Participant
Posts: 428
Joined: Thu Aug 16, 2007 11:38 pm
Location: Manali

Post by arvind_ds »

Write the value of the first variable into a file and then read it using the second variable.
Arvind
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

That functionality doesn't exist in BASIC, one can use "LIT" for constants, but those are evaluated at compile-time and not run-time.

You can work around the problem by using an array or dynamic array.

e.g.

Code: Select all

   Variables = ''
   Variables<1> = "test"
   Variables<2> = "1"
   NewValue = Variables<Variables<2>>
or

Code: Select all

   DIM Variables(10)

   MAT Variables = ''
   Variables(1) = "test"
   Variables(2) = "1"
   NewValue = Variables(Variables(2))
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

If by "job control" you mean in some hand-coded BASIC, you can just do the assignment without any "eval" needed: varC = varB, for example. If that's not working for you, we would need more details as to why not.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Craig - he means take the value of a variable as a variable name and assign that variable's value; sort of a like a variable being a pointer to the value of another.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Ah... sorry, more of an indirect method, it seems. Should have looked more closer at the example. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

If it is any consolation, my initial answer was identical to yours, but I managed to edit it quickly...
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

It's not, but... thanks! :oops:



:wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
urpandu
Participant
Posts: 1
Joined: Tue Mar 23, 2010 10:27 am

Re: Variable substitution in Job Control ?

Post by urpandu »

dcoueron wrote:Is there any way to substitute a variable name with its value in a job control ? (Some kind of eval function)

Example :
varA = "test"
varB = "varA"
I need to get varC = "test" by calling something like varC = eval(varB)

I think,, u need to write routines
Pandu Dhanawade
dcoueron
Participant
Posts: 19
Joined: Wed Sep 26, 2007 8:45 am
Location: Paris

Post by dcoueron »

Many thanks to every one.
I used arvind_ds's solution and it works well.

Sorry for the lack of precision ! :)
Damien
Post Reply