HLASM Language Reference

HLASM Language Reference HLASM Language Reference

faculty.cs.niu.edu
from faculty.cs.niu.edu More from this publisher
22.02.2015 Views

SETA Instruction | The result of C2A is the same as would be obtained from | &value SETA C'charstring' | except that C2A gives a zero result for null strings, and does not pair | apostrophes or ampersands before conversion. | Example | C2A('') has value | C2A('+') has value 78 | C2A('1') has value 241 | C2A('') has value -252645136 | D2A | Format: Function-invocation | Operands: Character | Output: D2A('decstring') converts a character string argument containing an | optional leading plus or minus sign followed by decimal digits to an arithmetic | value. Error conditions are detected if | the argument contains invalid characters | no digits are present following a sign | the argument length exceeds 11 characters | the resulting value is too large | the argument string is null. | The result of the D2A function is the same as | &value SETA decstring | except that SETA does not allow leading plus or minus signs. | Examples | D2A('') indicates an error condition | D2A('') has value | D2A('1') has value 1 | D2A('+1') has value 1 | D2A('-5') has value -5 | DCLEN | Format: Function-invocation | Operands: Character | Output: DCLEN('cexpr') returns the length of its argument string after pairs of | apostrophes and ampersands have been internally replaced by single | occurrences. No change is made to the argument. Such pairing occurs only | once; that is, three successive occurrences of an apostrophe or ampersand | will result in two occurrences, not one. | Examples | DCLEN('') has value (null string) | DCLEN('''') has value 1 (argument is a single apostrophe) | DCLEN('''''') has value 2 (argument is two apostrophes) | DCLEN('&&') has value 1 (argument is two ampersands) | DCLEN('a''''b') has value 3 (DCVAL string would be "a'b") | DCLEN('a''''b&&c') has value 5 (DCVAL string would be "a'b&c") | DCLEN('&&&''''''') has value 4 (DCVAL string would be "&&''") | Note: DCLEN is similar to DCVAL, except that DCLEN returns only the length | of the result, not the paired string. 354 HLASM V1R5 Language Reference

SETA Instruction FIND INDEX Format: Logical-expression, function-invocation Operands: Character Output: (string1 FIND string2) or FIND(string1,string2) finds the first match of any character from operand2 within operand1. The value returned by FIND indicates the position where the match occurs. FIND returns 0 if no match occurs or if either operand is a null string. Examples After the following statements &VAR contains the arithmetic value 3. Name Operation Operand &OP1 SETC 'abcdef' &OP2 SETC 'cde' &VAR SETA ('&OP1' FIND '&OP2') In the above example the character c in &OP2 is the first character found in &OP1. Consider the following example where the character c, in &OP1, has been replaced with the character g. Name Operation Operand &OP1 SETC 'abcdef' &OP2 SETC 'gde' &VAR SETA ('&OP1' FIND '&OP2') &VAR contains the arithmetic value 4. The character d in &OP2 is the first character found in &OP1. In the following example, the ordering of the characters in the second operand is changed to egd. Name Operation Operand &OP1 SETC 'abcdef' &OP2 SETC 'egd' &VAR SETA FIND('&OP1','&OP2') &VAR still contains the arithmetic value 4. Because FIND is looking for a single character from the character string, the order of the characters in the second operand string is irrelevant. Format: Logical-expression, function-invocation Operands: Character Output: INDEX('cexpr1','cexpr2') or ('cexpr1' INDEX 'cexpr2') locates the first occurrence of the second argument within the first argument, and returns the position of the match. A zero value is returned if: Either argument is null No match is found The second argument is longer than the first Examples INDEX('ABC','B') has value 2 INDEX('ABC','D') has value Chapter 9. How to Write Conditional Assembly Instructions 355

SETA Instruction<br />

FIND<br />

INDEX<br />

Format: Logical-expression, function-invocation<br />

Operands: Character<br />

Output: (string1 FIND string2) or FIND(string1,string2) finds the first<br />

match of any character from operand2 within operand1. The value returned<br />

by FIND indicates the position where the match occurs. FIND returns 0 if no<br />

match occurs or if either operand is a null string.<br />

Examples<br />

After the following statements &VAR contains the arithmetic value 3.<br />

Name Operation Operand<br />

&OP1 SETC 'abcdef'<br />

&OP2 SETC 'cde'<br />

&VAR SETA ('&OP1' FIND '&OP2')<br />

In the above example the character c in &OP2 is the first character found in<br />

&OP1. Consider the following example where the character c, in &OP1, has<br />

been replaced with the character g.<br />

Name Operation Operand<br />

&OP1 SETC 'abcdef'<br />

&OP2 SETC 'gde'<br />

&VAR SETA ('&OP1' FIND '&OP2')<br />

&VAR contains the arithmetic value 4. The character d in &OP2 is the first<br />

character found in &OP1.<br />

In the following example, the ordering of the characters in the second operand<br />

is changed to egd.<br />

Name Operation Operand<br />

&OP1 SETC 'abcdef'<br />

&OP2 SETC 'egd'<br />

&VAR SETA FIND('&OP1','&OP2')<br />

&VAR still contains the arithmetic value 4. Because FIND is looking for a single<br />

character from the character string, the order of the characters in the second<br />

operand string is irrelevant.<br />

Format: Logical-expression, function-invocation<br />

Operands: Character<br />

Output: INDEX('cexpr1','cexpr2') or ('cexpr1' INDEX 'cexpr2') locates<br />

the first occurrence of the second argument within the first argument, and<br />

returns the position of the match. A zero value is returned if:<br />

Either argument is null<br />

No match is found<br />

The second argument is longer than the first<br />

Examples<br />

INDEX('ABC','B') has value 2<br />

INDEX('ABC','D') has value <br />

Chapter 9. How to Write Conditional Assembly Instructions 355

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

Saved successfully!

Ooh no, something went wrong!