Welcome Serena Central users! CLICK HERE
The migration of the Serena Central community is currently underway. Be sure to read THIS MESSAGE to get your new login set up to access your account.
SteveEly Absent Member.
Absent Member.
1527 views

Setting a windows environment variable.

Jump to solution

I am trying to set a windows variable in COBOL that I will be able to read in a C# program I am calling from COBOL.

"SET testvar=xx" works at a DOS prompt.

However the following does not work.

move "SET testvar=xx" to AFLD60
CALL "C$SYSTEM" USING AFLD60, 97 END-CALL. | Called ASYNCH so no delay

Any ideas would be most appreciated.

Thanks,

Steve

 

0 Likes
1 Solution

Accepted Solutions
Bruce_Sinclair Absent Member.
Absent Member.

RE: Setting a windows environment variable.

Jump to solution

C$SYSTEM will execute a new command prompt to run the SET command.  That will set the environment variable there and that environment will go away when the command prompt exits.  To set an environment variable in the same environment as your COBOL run unit, use the Format 6 SET statement:  SET ENVIRONMENT.

View solution in original post

0 Likes
3 Replies
Bruce_Sinclair Absent Member.
Absent Member.

RE: Setting a windows environment variable.

Jump to solution

C$SYSTEM will execute a new command prompt to run the SET command.  That will set the environment variable there and that environment will go away when the command prompt exits.  To set an environment variable in the same environment as your COBOL run unit, use the Format 6 SET statement:  SET ENVIRONMENT.

View solution in original post

0 Likes
rstoll Absent Member.
Absent Member.

RE: Setting a windows environment variable.

Jump to solution

Agreeing with BSinclair    SET ENVIRONMENT e TO ws-vbl  

and the environmental variables are available to any subprogram called.  Wouldn't leave home without it.

In the subprograms, ACCEPT ws-var FROM ENVIRONMENT e  

0 Likes
SteveEly Absent Member.
Absent Member.

RE: Setting a windows environment variable.

Jump to solution

Yes, we use SET ENVIRONMENT quite extensively, however since I have to call my C# .exe with C$SYSTEM it wont help. I will flag your response as the answer, because I have found a simpler work around that does not involve environment variables.

Thanks,

Steve

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.