TITLE:Back-to-Basics: System() - Part 2

ISSUE:Multi-Value Solutions Sep'98

AUTHOR:Nathan Rector

COMPANY:Natec Systems

EMAIL:nater@northcoast.com

HTTP:www.northcoast.com/~nater/

Syntax: var = SYSTEM(number)

The BASIC command SYSTEM() provides an interface to a number of system variables. The SYSTEM() command give you valuable information about what is going on after executing different BASIC or TCL commands depending on the number specified. Since each SYSTEM() variable is different, please look at each one for how they work:

There are 41 different variables available with the SYSTEM() command. Last month we covered the context-orientated variable and the printer related variables.

7 - Returns the terminal "type" code, as defined by the "term" command.

8 - Returns the block size at which the tape was last attached.

9 - Returns the current cpu millisecond count.

10 - Checks the current stack (ston) condition. Returns 1 (one) if the stack is on, or 0 (zero), if not.

*

IF NOT(SYSTEM(10)) THEN

* input stack is not on. display the label

CRT "Input TODAYS date"

END

INPUT TODAY

11 - Checks for an externally-generated active list.

In R83, it returns "0" if there is no active list, or "1" (one) if an active list exists.

In AP, it returns "0" if there is no active list, or "n" (the actual number of items selected), if an active list exists.

This has nothing to do with the internal (Pick/BASIC) "select" statement, which requires a "readnext" to determine if any items were selected.

ie:

EXECUTE \SELECT EMPLOYEE\

IF SYSTEM(11) THEN

CRT "ACTIVE LIST"

END ELSE

CRT "LIST NOT ACTIVE"

END

12 - Returns the system time in milliseconds.

13 - Forces an rqm (terminates timeslice) and returns a 1. Deactivates the process in the scheduling queue until its next turn.

FOR I = 1 TO 100

X = SYSTEM(12) ;* does the same thing as RQM

NEXT I

14 - Returns the number of bytes in the terminal type-ahead input buffer. If you want to process a loop statement, but allows the user to exit the loop whenever they wish this option comes in handy.

X = ""

LOOP

UNTIL X = "END" DO

CRT "Loop"

*

IF SYSTEM(14) THEN

* someone has pressed a key on the keyboard

INPUT X

END

REPEAT

15 - Returns the TCL verb option{s} that are in effect.

TEST

001 *

002 CRT "Options: ": SYSTEM(15) ;* returns anything after the ( at TCL

003 END

>TEST (N

Options: N

16 - Returns the current process or EXECUTE level. Some systems can only have so many nested EXECUTE statements. SYSTEM(16) tells you how many EXECUTEs have been done.

TEST

001 *

002 CRT SYSTEM(16)

003 EXECUTE \TEST\

004 END

Warning: This program continues to run until a break key is hit or until it crashes when it processes too many nested EXECUTE statements

17 - Returns the message numbers (item-ids) returned by the previous "execute" statement, separated by attribute marks.

EXECUTE \CREATE-FILE BLANK 1 1\

EXECUTE \SELECT BLANK\

CRT SYSTEM(17) ;* returns 401. (error code for no items)