SETLOCAL

  ──SETLOCAL()────────

SETLOCAL saves the current working drive and directory, and the current values of the OS/2 environment variables that are local to the current process.

For example, SETLOCAL can be used to save the current environment before changing selected settings with the VALUE function. To restore the drive, directory, and environment, use the ENDLOCAL function.

SETLOCAL returns a value of 1 if the initial drive, directory, and environment are successfully saved, and a value of 0 if unsuccessful. If SETLOCAL is not followed by an ENDLOCAL function in a procedure, then the initial environment saved by SETLOCAL will be restored upon exiting the procedure.

Here is an example:

/* current path is 'C:\PROJ\FILES' */
n = SETLOCAL()        /* saves all environment settings    */

/* Now use the VALUE function to change the PATH variable. */
p = VALUE('Path','C:\PROC\PROGRAMS'.'OS2ENVIRONMENT')

/* Programs in directory C:\PROC\PROGRAMS may now be run   */

n = ENDLOCAL()  /* restores initial environment (including */
                /* the changed PATH variable, which is   */
                /* once again 'C:\PROJ\FILES'              */

┴╓: Unlike their counterparts in the OS/2 Batch language (the Setlocal and Endlocal statements), the REXX SETLOCAL and ENDLOCAL functions can be nested.


[Back: RIGHT]
[Next: SIGN]