Keywords are special variables which begin with the character &. Some of them can be set to different values by the user while some cannot. They are used to control and observe various run-time aspects of the program and retrieve pattern primitives.
&ABEND If a positive value is assigned to &ABEND, an error message is given at termination of the program. The maximum of &ABEND and &CODE is used as the return code for the program run. A negative value is treated as zero. In Windows the maximum value is clamped to 2147483647. In Linux the maximum value is clamped to 255. In Windows you can show the return code using "echo %ERRORLEVEL%". In Linux you can show the return code using "echo $?". If you do not wish to have an error message, use just &CODE.
&ABORT is the value of the primitive pattern ABORT. The value of this keyword cannot be changed.
&ALPHABET is a string of the 256 characters in the ASCII collating sequence. It is useful for dealing with non-printable characters. The value of this keyword cannot be changed. See the BASIC manual for a complete table of these characters.
&ANCHOR anchors all pattern matches when its value is nonzero. This is equivalent to placing the primitive pattern POS(0) in front of every pattern being matched. The default value of this keyword is zero.
&ARB is the value of the ARB primitive pattern. The value of this keyword cannot be changed.
&BAL is the value of the BAL primitive pattern. The value of this keyword cannot be changed.
&CODE is used to set a return code for SNOBOL5 program execution. The maximum of &ABEND and &CODE is used as the return code for the program run. A negative value is considered to be zero. In Windows the maximum value is clamped to 2147483647. In Linux the maximum value is clamped to 255. In Windows you can show the return code using "echo %ERRORLEVEL%". In Linux you can show the return code using "echo $?". If you wish to have an error message at program termination, use just &ABEND.
&DIG is a string of the decimal digits: "0123456789". The value of this keyword cannot be changed.
&DUMP causes a dump of all natural variables and keywords to be printed when the program execution ends, if this keyword value is not zero. The default value of this keyword is zero. The command line option /D causes the keyword &DUMP to default to 1 instead of zero.
&DS returns the slash character for path names. The value is the string "\" for Windows and "/" for Linux. The value of this keyword cannot be changed.
&E is the real number e: 2.7182818284590... The value of this keyword cannot be changed.
&ERRLIMIT sets the number of run-time conditional errors which can be allowed before error termination of execution. Each error decrements this keyword by 1 and causes the statement in which the error occurred to fail. See &ERRTYPE to get the most recent error type number. The default value of this keyword is zero.
&ERRTYPE contains the error number of the most recent execution time error. By tracing the value of this keyword, one can intercept non-fatal run time errors. See the GREEN book for the variaous error type descriptions. If &ERRLIMIT is set to an integer greater than zero, then some of the possible errors won't terminate the program and &ERRTYPE can be checked. Your program cannot assign a value to this keyword.
&FAIL is the value of the FAIL primitive pattern. The value of this keyword cannot be changed.
&FENCE is the value of the FENCE primitive pattern. The value of this keyword cannot be changed.
&FLTDEC is used to control when REAL values are displayed using e format. If the first significant digit is more than &FLTDEC positions away from the decimal point, then e format is used. If &FLTDEC is set to -1, then e format is always used except that zero is always displayed as "0.". &FLTDEC defaults to a value of 12.
&FLTSIG is used to control how many significant digits to display when REAL values are displayed as STRINGs. &FLTSIG can be in the range of 1 to 14. If it is set outside this range, it is limited to the allowed range. &FLTSIG defaults to a value of 12. However, if the resulting STRING has trailing zeros, those are trimmed off.
&FNCLEVEL indicates at what function invocation depth the program is currently executing. The initial value is zero. The keyword is incremented by one on every call and decremented by one on every return. Your program cannot assign a value to this keyword.
&FTRACE causes all user-defined function calls and returns to be traced with printed records when the value of this keyword is positive. Each trace record printed decrements the value of &FTRACE. See the TRACE() function for more information about tracing.
&FULLSCAN disables the length failure heuristic during pattern matching, when the value of this keyword is nonzero. The default value of this keyword is zero. Please refer to Griswold's SNOBOL5 manual for a detailed understanding of this keyword. Most pattern matches are not affected by quickscan, the default. When fullscan mode is in effect, some patterns may cause much longer execution and even infinite loops.
&INFINITY is the floating point value of infinity. The value converts to the character string 'INFINITY' and can be converted back to a floating point value. Infinity can also be created through computations such as dividing a non-zero number by floating point zero. The value of this keyword cannot be changed.
&INPUT permits input variables to read from their assigned file when this keyword is nonzero. The initial value of this keyword is one. This keyword is useful for disabling input or improving execution speed in sections of the program where there is no input.
&IOERR #### is not implemented ####
&LASTNO gives the statement number of the last statement executed. This is useful for debugging your program and for use in programmer error handling routines. Your program cannot assign a value to this keyword.
&lc is a string of the lower case (minuscule) alphabetic letters: "abcdefghijklmnopqrstuvwxyz". The value of this keyword cannot be changed. See also the upper case (majuscule) version &UC.
&MAXARB is a protected keyword which contains the value of the pattern MAXARB. If a new value is assigned to MAXARB, the pattern can be recovered using &MAXARB.
&MAXLNGTH specifies the maximum length character string value allowed. The initial value of this keyword is 63999999952. Note that this implementation of SNOBOL5 supports character strings up to the length of 63,999,999,952 characters, almost 64 gigabytes.
&NAN is the value NAN (Not A Number) as defined in the IEEE 754 Standard floating point specification. This value is generated by floating point operations for which the correct answer cannot be computed. For example, a floating point divide of zero by zero produces a NAN result. Floating point operations which have a NAN as an input operand propagate the NAN to their results. In this way, the final answer will be NAN if any of the dependent operands were NAN or results from questionable computations. The NAN converts to a character string as 'NaNsss:ccc' where sss is the statement number (&STNO) creating the NAN and ccc is the &STCOUNT of when the NAN was created. You can test for a NAN in the floating point form by using the ISNAN, IDENT or DIFFER predicates but not LT LE GT GE EQ or NE. The value of this keyword cannot be changed.
&OS specifies the name of the operating system SNOBOL5 is being executed on. The value is either "Windows" or "Linux". This can be used to handle differences in the environments, especially when using the SYSTEM(cmd) function.
&OUTPUT permits output variables to write to their assigned file when this keyword is nonzero. The initial value of this keyword is one. This keyword is useful for disabling output or improving execution speed in sections of the program where there is no output.
&PARM is a character string consisting of the characters on the command line, used to invoke SNOBOL5. The fields may separated by blanks or CHAR(0) characters. The characters after a ":" are not parsed for I/O assignments or options. Thus any data after the colon (":") character can be used within the SNOBOL program for its own purposes. The value of this keyword cannot be changed.
&PI is the real number π: 3.141592653589... The value of this keyword cannot be changed.
&REM is the value of the REM primitive pattern. The value of this keyword cannot be changed.
&RTNTYPE is either 'RETURN', 'FRETURN' or 'NRETURN' depending on how the last programmer-defined function returned. The initial value of this keyword is the null string. Your program cannot assign a value to this keyword.
&STAT is a new keyword which can be set to zero if no run-time statistics are to be printed at termination. A nonzero value will cause run-time statistics to be printed on unit 6. &STAT defaults to the value 0. The -v option on the command line invoking SNOBOL5 sets &STAT to one to show all output and statistics.
&STCOUNT gives the number of statements executed. Its value is incremented by one when the statement begins. Your program cannot assign a value to this keyword. If this number reaches the value of &STLIMIT, the program is terminated.
&STFCOUNT gives the number of statements that failed. This keyword is incremented by one when a statement fails. Your program cannot assign a value to this keyword.
&STLIMIT sets the limit for how many statements may be executed in this program before it is terminated. The initial value of this keyword is 9223372036854775807. This keyword is useful for debugging programs that may be going into an infinite loop. Note that ten cntl-break's will interrupt the program and show were it stopped.
&STNO This keyword gives the number of the statement currently being executed. Your program cannot assign a value to this keyword.
&SUCCEED is the value of the SUCCEED primitive pattern. The value of this keyword cannot be changed.
&TRACE permits a trace record defined by the TRACE() function to be printed when its value is greater than zero. When a trace record defined by TRACE() is printed, this keyword is decremented by one. The initial value of &TRACE is zero.
&TRIM causes all trailing blanks and tabs to be removed from all input records when this keyword is nonzero. The initial value of this keyword is zero.
&UC is a string of the upper case (majuscule) alphabetic letters: "ABCDEFGHIJKLMNOPQRSTUVWXYZ". The value of this keyword cannot be changed. See also the lower case (minuscule) version &lc.
Prior Page, Next Page, First Page of the Oregon SNOBOL5 Reference