Dos: Calls to the Operating System

      $func Arg    s.Int = e.Arg;
      $func Args   = e.Args;
      $func GetEnv e.VarName = e.Value;
      $func Time   = e.String;
      $func Exit   s.ReturnCode = ;
      $func Delay s.MSeconds = ;
      $func Sleep s.Seconds = ;
      $func Random s.Max = s.Rand;  /* 0 <= s.Rand < s.Max */
      $func Randomize = ;

These functions provide some ways of calling the operating system.

The arguments of the functions must satisfy the following restrictions. s.Int must be a non-negative integer, e.VarName a sequence of character and word symbols, s.ReturnCode an integer ranging from 0 to 255. If one or more of the above restrictions are violated, the result returned by the functions is $error(Fname "Invalid argument"), where Fname is the function's name.

Arg returns the command line argument having the number s.Int. If there is no such argument, an empty ground expression is returned.

Args returns the command line arguments as a sequence of terms, each term being a sequence of charachter symbols enclosed in parentheses.

GetEnv returns the value associated in the OS environment with the variable having the name e.VarName.

Time returns the current date and time represented by a ground expression of the form
      DD MMM YYYY HH:MM:SS.SS

where DD is the month's day, MMM the abbreviated month name ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"), YYYY the year number, HH:MM:SS.SS the ours, minutes, seconds, and hundredth of a second. DD, YYYY, HH, MM, SS are represented by integers, MMM by a word. The separators are character symbols ' ', ':' and '.'.

Exit terminates the execution of the program, with the completion code being equal to s.ReturnCode. If the program terminates in the normal way, i.e. the evaluation of the call to the main function Main terminates, the completion code depends on the result returned by the function Main. If the result is a ground expression, the completion code is equal to 0. Otherwise, if the result has the form $error(Ge), the completion code is equal to 100.

Delay suspends the current program from execution for the number of milliseconds specified by s.MSeconds. The interval is accurate only to the nearest hundredth of a second, or the accuracy or the MSDOS clock, whichever is less accurate.

Sleep suspends the current program from execution for the number of seconds specified by s.Seconds. The interval is accurate only to the nearest hundredth of a second, or the accuracy or the MSDOS clock, whichever is less accurate.

Random returns a pseudorandom integer in the range 0 to s.Max minus 1.

Randomize initializes the random number generator with a random value.