Product SiteDocumentation Site

6.2. The Local Directory (.LOCAL)

The Local environment object is a directory of interpreter instance objects that are always accessible. You can access objects in the Local environment object in the same way as objects in the Environment object. The Local object contains the .INPUT, .OUTPUT, .ERROR, .DEBUGINPUT, and .TRACEOUTPUT Monitor objects used for Rexx console I/O, the .STDIN, .STDOUT, and .STDERR output streams that are the default I/O targets, and the .STDQUE RexxQueue instance used for Rexx external queue operations.
Because both .ENVIRONMENT and .LOCAL are directory objects, you can place objects into, or retrieve objects from, these environments by using any of the directory methods ([],[]=, PUT, AT, SETENTRY, ENTRY, or SETMETHOD). To avoid potential name clashes with built-in objects and public objects that Rexx provides, each object that your programs add to these environments should have a period in its index.
Starting with ooRexx 4.2.0 a new object is available in the .LOCAL directory. The object is a Rexx Array of all the command line options supplied to the program. Normally all the command line objects are combined into single string and passed to the script as an argument retrievable via the BIF ARG(1). The array supplied by the .LOCAL environment is a direct collection of the individual C arguments passed to the program. The name of this array is SYSCARGS.

Example 6.1. .LOCAL

/* .LOCAL example--places something in the Local environment directory */
.local~my.alarm = theAlarm
/* To retrieve it                                                      */
say .local~my.alarm
/* Another .LOCAL example (Windows) */
.environment["MYAPP.PASSWORD"] = "topsecret"
.environment["MYAPP.UID"] = 200

/* Create a local directory for my stuff */
.local["MYAPP.LOCAL"] = .directory~new

/* Add log file for my local directory                                 */
.myapp.local["LOG"] = .stream~new("myapp.log")
say .myapp.password                    /* Displays "topsecret"         */
say .myapp.uid                         /* Displays "200"               */

/* Write a line to the log file */
.myapp.local~log~lineout("Logon at "time()" on "date())

/* Redirect SAY lines into a file:  */
.output~destination(.stream~new("SAY_REDIRECT.TXT"))
say "This goes into a file, and not onto the screen!"
/* .LOCAL example--get the individual command line arguments */
cmdargs = .local~syscargs
do carg over cmdargs
   say carg
end