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 />

which reads a variable length text string enclosed by matched delimiters. This form of the read<br />

statement skips to the next nonblank character in the input data, treating this character as a leading<br />

delimiter, and then reads until the next occurrence of this same character. The character string may<br />

begin in any record column position and extend over any number of input records. Any nonblank<br />

character may serve as a delimiter for any individual read. For example, the statement:<br />

read TVAR1, TVAR2 as 2 T *<br />

when reading the following data record:<br />

column number<br />

0 1 2 3 4...<br />

1234567890123456789012345678901234567890...<br />

/A simple phrase/ 'Two words'<br />

is equivalent to:<br />

and<br />

let TVAR1 = "A simple phrase"<br />

let TVAR2 = "Two words"<br />

A text variable may be included in the variable list of a print statement. The print format information<br />

should contain a field of asterisks denoting the positions to be occupied in the printed<br />

line. If the text string to be printed contains more characters than there are allocated print positions,<br />

only the indicated number of characters will appear in the output. Conversely, if more positions are<br />

allocated than there are characters, the unfilled positions will appear as blanks. Thus, the statement:<br />

print 1 line with TVAR1, TVAR2 thus<br />

**************** ********<br />

produces the result:<br />

ANTIDISESTABLISH<br />

IS<br />

A technique for producing variable-length string output is described in Chapter 3.<br />

2.21 Operations With Text Variables<br />

Although arithmetic operators cannot operate on text mode variables, certain logical expressions<br />

can use text variables. The most usual of these is comparison for equality; thus:<br />

if NAME = "LEWIS CARROLL"<br />

Such comparisons between text variables or literals are treated on a character-by-character basis,<br />

starting from the first character position and proceeding left to right. If two text strings differ in<br />

71

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

Saved successfully!

Ooh no, something went wrong!