SPL to HP C/XL Migration Guide (30231-90001)
5-25
---------------------------------------------------------------------------------------------
| | |
| SPL | HP C/XL Equivalent |
| | |
---------------------------------------------------------------------------------------------
| | |
| A < B(3), (5),3 | strncmp(A,&B[3],5) < 0 |
| | |
| B(5) >= *PB,(5) |
No equivalent
|
| | |
| A <= "string" | strcmp(A,"string") <= 0 |
| | |
| B = ("ab",%07) | strcmp(B,"ab\7") == 0 |
| | |
| C <> ALPHA | !isalpha(C) |
| | |
---------------------------------------------------------------------------------------------
The second example above, which compares bytes to a previously stacked
PB-relative address, is a hardware-dependent construct that has no
equivalent in HP C/XL.
The isalnum, isalpha, isdigit, strcmp, and strncmp functions are all
members of the standard HP C/XL function library.
Some more examples, used here as condition clauses of IF statements:
---------------------------------------------------------------------------------------------
| | |
| SPL | HP C/XL Equivalent |
| | |
---------------------------------------------------------------------------------------------
| | |
| IF A = B,(5) THEN... | if (strncmp(A,B,5) == 0)... |
| | |
| IF A <> B,(5) THEN... | if (strncmp(A,B,5) != 0)... |
| | |
| IF A > B,(5) THEN... | if (strncmp(A,B,5) > 0)... |
| | |
| IF A < B,(5) THEN... | if (strncmp(A,B,5) < 0)... |
| | |
| IF A >= B,(5) THEN... | if (strncmp(A,B,5) >= 0)... |
| | |
| IF A(5) = "abc" THEN... | if (strcmp(&A(5),"abc") == 0)... |
| | |
| IF B <> "abc" THEN... | if (strcmp(B,"abc") != 0)... |
| | |
---------------------------------------------------------------------------------------------
These HP C/XL statements are equivalent to the SPL versions if the byte
strings (character strings) being compared do not contain a NUL charac-
ter in the range being tested.
The SPL byte comparisons scan exactly the number of characters indicated
by
count
or the number of character values in the
string
or
value-
group
s.
By definition, an HP C/XL string is terminated by the ASCII NUL character
('\0', numeric value 0). HP C/XL functions that scan strings usually
stop scanning when they find a NUL character or when they reach a
specified count.
However, because NUL equals zero and is the lowest character value,
these comparison functions should work well, except in the following