18.10.2014 Views

SIMSCRIPT II.5 Programming Language

SIMSCRIPT II.5 Programming Language

SIMSCRIPT II.5 Programming Language

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>SIMSCRIPT</strong> <strong>II.5</strong> <strong>Programming</strong> <strong>Language</strong><br />

length, the shorter string is considered to be extended with blanks for comparison purposes. Comparisons<br />

are not limited to equality or inequality. However, the result of "less than" or "greater than"<br />

comparisons depends on the collating sequence of the internal character sequence used. This is<br />

based on the implementation and the <strong>SIMSCRIPT</strong> <strong>II.5</strong> User Guide should be consulted. On all implementations,<br />

however, the null string compares less than all other strings.<br />

2.21.1 Concatenation: CONCAT.F(text1, text2...textn)<br />

The concat.f function returns a text variable by concatenating the text variables or text expressions<br />

given as arguments. To illustrate the effect, let the text variables STRING1 and<br />

STRING2 be assigned the characters "PIANO" and "FORTE", respectively. The effect of the statement:<br />

let LONGNAME = concat.f(STRING1, STRING2)<br />

is to assign the characters "PIANOFORTE" to LONGNAME. Similarly,<br />

let LUNCH = concat.f("HAM", "AND", "EGGS")<br />

assigns "HAMANDEGGS" to LUNCH. The concatenation is in the order of the given arguments. If any<br />

argument has a null value, the remaining strings are concatenated normally.<br />

2.21.2 Substring: SUBSTR.F(text, index, length)<br />

The substr.f function provides access to a substring within a text variable. The substring is<br />

specified by two integer values, a start position within the source string, and the substring length.<br />

The first character of the string is referenced by an index of 1. If A and B are text variables, then the<br />

statement:<br />

let B = substr.f(A,I,J)<br />

copies J characters, starting from the I th character position in A to the character string B. A remains<br />

unchanged. For example, if A = "<strong>SIMSCRIPT</strong> <strong>II.5</strong>", then:<br />

let B = substr.f(A,4,6)<br />

assigns the characters "SCRIPT" to B.<br />

Unlike most functions, substr.f may be used on the left-hand side of an assignment statement<br />

to replace a substring within a text variable. If string A has the value "FOOTBALL", then the<br />

effect of the statement:<br />

let substr.f(A,1,4) = "GOLF"<br />

is to replace the first four characters in A, giving it the value "GOLFBALL". For either use, the start<br />

position specified must be 1 or greater. The substr.f function may not be used to extract or replace<br />

characters beyond the length of the string, A. If the substring is so specified, only the remain-<br />

72

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

Saved successfully!

Ooh no, something went wrong!