Page 1 of 1

Project Variable

Posted: Wed Oct 26, 2005 7:53 am
by Veni
Any body know , how to invoke project variable that is environment variable in subroutine....

i created one variable say Hash_file_location in project level environment variable...

i need to invoke this variable in my subroutine. is it possible i know how to invoke this variable from job parameter.... using #$Hash_file_location#

but i want to invoke in my subroutine

Posted: Wed Oct 26, 2005 8:34 am
by kcbland
Environment variables have to be setup in the job as job parameters. As for getting any variable into a subroutine (I assume you mean before/after transformer/job subroutine call) you have to pass it as the argument. Your subroutine needs to get it from the argument. Otherwise, you will need to do an "env" command from inside your subroutine and parse it from the screen results of the env command.

Posted: Wed Oct 26, 2005 9:16 am
by Veni
kcbland wrote:Environment variables have to be setup in the job as job parameters. As for getting any variable into a subroutine (I assume you mean before/after transformer/job subroutine call) you have to pass it as the argument. Your subroutine needs to get it from the argument. Otherwise, you will need to do an "env" command from inside your subroutine and parse it from the screen results of the env command.

Please tell me how to parse " env" command from inside my subroutine

Posted: Wed Oct 26, 2005 10:49 am
by ArndW
Veni,

in a routine you can issue

Code: Select all

EnvironmentString = DSExecute('UNIX','env',ErrorCode)
The EnvironemtString will contain the UNIX output of the env command, with all <LF> converted to @FM. You can then write some code to loop through all the values to find the ones you are interested in.

Posted: Wed Oct 26, 2005 10:57 am
by gsherry1
Here is example of calling external program. You should adapt this to call env instead.

Expression="env | grep '^ABC='"
call DSExecute("UNIX", Expression, Output, SystemReturnCode)

Output would then be assigned something like "ABC=somevalue"

Posted: Wed Oct 26, 2005 7:46 pm
by vmcburney
Normally you want to avoid plucking env variables from within a routine as it breaks good modular coding practices. Kind of like using global variables in Visual Basic code. The project specific environment variables are set as the default values for job parameters, it is possible that someone will run the job and change those defaults (for example change the hash file location) when the run or schedule the job, so your jobs will end up using one value and your routines another value.

Passing all variables in a arguments to the routine is a better way to go and it is very easy to set up from a Sequence job.

Posted: Thu Oct 27, 2005 11:10 pm
by Veni
vmcburney wrote:Normally you want to avoid plucking env variables from within a routine as it breaks good modular coding practices. Kind of like using global variables in Visual Basic code. The project specific environment variables are set as the default values for job parameters, it is possible that someone will run the job and change those defaults (for example change the hash file location) when the run or schedule the job, so your jobs will end up using one value and your routines another value.

Passing all variables in a arguments to the routine is a better way to go and it is very easy to set up from a Sequence job.

i want to get access userdefine variable in project environment from my subroutine ,

it is entripted value that in job i can invoke #$HASH_PATH_Par# BUT I don't know how to invoke from subroutine

Posted: Fri Oct 28, 2005 1:45 am
by ray.wurlod
Look for the function DSGetParamInfo() in on-line help.