18.10.2014 Views

SIMSCRIPT II.5 Programming Language

SIMSCRIPT II.5 Programming Language

SIMSCRIPT II.5 Programming Language

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Programming</strong> <strong>Language</strong> Concepts<br />

define variable list as alpha variables<br />

An alpha variable may contain any character from the character set, including the blank character.<br />

A character value is assigned to an alpha variable by delimiting the character literal with quotes<br />

("). If the literal comprises more than one character, the first character is assigned. (When an<br />

alpha variable contains more than one character, the number of characters equivalent to the alpha<br />

variable size will be extracted.) For example:<br />

let ALPHAVAR = "A"<br />

The quotation mark is assigned by writing four successive quotation marks (""""). Alpha variables<br />

may be assigned and compared. They may also be used in arithmetic operations, but care must be<br />

taken that such use is meaningful. It must also be noted that the effect of such use may differ with<br />

various implementations, as various internal character representations have different numeric values.<br />

An example of the use of an alpha variable might be the use of alphabetic item codes in the<br />

inventory program mentioned earlier:<br />

define ITEM.CODE as an alpha variable<br />

define STOCK as a 1-dimensional integer array<br />

.<br />

.<br />

read ITEM.CODE and QUANTITY<br />

if ITEM.CODE "X"<br />

subtract QUANTITY from STOCK(ITEM.CODE)<br />

always<br />

.<br />

.<br />

However, a similar effect may be achived without resorting to such implementation-dependent code.<br />

2.22.1 TEXT to ALPHA Conversion: TTOA.F(text)<br />

The system function ttoa.f returns the first character(s) of the given text variable as an alpha<br />

variable. Although typically only one character is returned, more may be given depending on the implementation<br />

and computer option selected. If the null string is given, a blank character(s) is returned.<br />

2.22.2 ALPHA to TEXT Conversion: ATOT.F(alpha)<br />

A complementary function, atot.f, generates a text representation of the given alpha variable.<br />

In general, this is a single character string, but alpha representation may vary on some systems.<br />

Consult the user's manual.<br />

2.23 Recursive Routines<br />

All <strong>SIMSCRIPT</strong> <strong>II.5</strong> routines are recursive, meaning that they can call upon themselves. The concept<br />

of recursion is commonly exemplified using a procedure evaluating the factorial of a number.<br />

The factorial of a number is defined by:<br />

75

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!