login  |  contact us  |  sitemap
 
MySybase Corporate Products Solutions Support Education Downloads e-Shop
This document was: Needs Work Excellent Fair     
 

 
Environment Variables and VX-REXX

There may be situations where in the VX-REXX project environment variables are required to be set. In the config.sys file an environment variable is set using the Set command examples in this document.


Environment Variables and VX-REXX
Abstract

There may be situations where in the VX-REXX project environment variables are required to be set. In the config.sys file an environment variable is set using the Set command. For example, the VX-REXX environment variable in the config.sys should look like:

Set VXREXX=C:\VXREXX
Executing the SET command to set an environment variable within a VX-REXX project will have no effect. This document will discuss why it has no effect and how to accomplish this.

The Concept of Sessions

Under OS/2, a program executes as a process. Each process that is started is considered to be running in its own session. There are many types of sessions in OS/2: DOS, WINOS2, Presentation Manager (PM) and OS/2. A session can be defined as a logical unit of the screen, keyboard and mouse. When working with a session, its environment and the resources allocated to it are independent of all other concurrent sessions. When a session is created, its environment is inherited from its parent environment. For example, when an OS/2 window is created, its parent is the OS/2 desktop and thus inherits its environment settings from the config.sys file.


The SET Command
A child sessions environment variables affect only that session not its parent or any other sessions. The SET command can be used to add or change environment variables from a command line session. SET is a command built into the command shell and thus requires to be run in a command line session. If a suitable session is not available a child session will be spawned and SET will be executed there.

Setting the Environment within VX-REXX

VX-REXX programs run in a PM session. Using SET to change the environment of the VX-REXX session will not work. As stated previously, SET requires the command processor. Thus, when SET is executed within VX-REXX, it creates a child command session and sets the desired variable in that child session. Meanwhile the parent PM session that the VX-REXX project is running in is unaffected. In order to overcome this behavior use the REXX VALUE function. Using this function will set the environment variable for the VX-REXX session.


Example:
If current environment is as such: Foo=5; Bar=C:\VXREXX ; to changes these values do the following:

  env = OS2ENVIRONMENT
  VALUE(Foo, 8, env)  /* returns 5 and sets Foo=8 */
  VALUE(Bar, D:\VXREXX,env) /* returns C:\VXREXX sets Bar=D:\VXREXX */

For more information on the VALUE function please see the REXX Information on-line reference.
1



Back to Top

  Document Attributes
Content Id: 44369 Last Revised: January 30, 1996
Authorization: Public Focus: Technical
Document Library: Tips Products: Watcom VX-REXX
Solutions: Not Solution Specific Expertise Level: 4-all
Technical Topics: Application Development