$Lstr X2C: Difference between revisions
m (1 revision) |
mNo edit summary |
||
Line 2: | Line 2: | ||
<span class="pageSubtitle"><section begin="desc" />Convert from hexadecimal to byte string<section end="desc" /></span> | <span class="pageSubtitle"><section begin="desc" />Convert from hexadecimal to byte string<section end="desc" /></span> | ||
<p class="warning">Most Sirius $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for the $Lstr_X2C function is [[ | <p class="warning">Most Sirius $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for the $Lstr_X2C function is the [[HexToString (String function)]].</p> | ||
This function converts from a hexadecimal encoded string to the decoded byte string. It is identical to $X2C (see the ''"Model 204 User Language Manual"''), except it is longstring capable. | This function converts from a hexadecimal encoded string to the decoded byte string. It is identical to $X2C (see the ''"Model 204 User Language Manual"''), except it is longstring capable. | ||
Line 13: | Line 11: | ||
The returned value is the hexadecimal decoding of the argument string. If the argument is not a valid hexadecimal encoding, the null string is returned. | The returned value is the hexadecimal decoding of the argument string. If the argument is not a valid hexadecimal encoding, the null string is returned. | ||
==Syntax== | ==Syntax== | ||
<p class="syntax"><section begin="syntax" /> %DECODED = $Lstr_X2C(string) | <p class="syntax"><section begin="syntax" /> %DECODED = $Lstr_X2C(string) | ||
Line 18: | Line 17: | ||
<p class="caption">$Lstr_X2C Function | <p class="caption">$Lstr_X2C Function | ||
</p> | </p> | ||
<p class="caption">%DECODED is set to the hexadecimal decoding of | <p class="caption">%DECODED is set to the hexadecimal decoding of '''string'''</p> | ||
For example, the following code | For example, the following code | ||
<p class="code"> PRINT $Lstr_X2C('D985844099A494') | <p class="code"> PRINT $Lstr_X2C('D985844099A494') | ||
</p> | </p> | ||
would print <tt>Red rum</tt>, which is the character representation of the EBCDIC characters represented in hexadecimal as "D985844099A494 | |||
would print <tt>Red rum</tt>, which is the character representation of the EBCDIC characters represented in hexadecimal as "D985844099A494". | |||
You can check for an invalid hexadecimal encoding by checking for the null string return value from $Lstr_X2C. Of course, if it is possible that the argument is null, the null string is a valid returned value. If you need to check for errors, and the null string is a possible argument value, you can use an approach such as the following: | You can check for an invalid hexadecimal encoding by checking for the null string return value from $Lstr_X2C. Of course, if it is possible that the argument is null, the null string is a valid returned value. If you need to check for errors, and the null string is a possible argument value, you can use an approach such as the following: | ||
<p class="code"> %STR = $Lstr_X2C(%IN) | <p class="code"> %STR = $Lstr_X2C(%IN) | ||
IF %STR EQ '' | IF %STR EQ '' | ||
Line 35: | Line 35: | ||
</p> | </p> | ||
[[$Lstr_C2X]] is the inverse of $Lstr_X2C. | |||
This $function is new in Version 6.8 of the ''[[Sirius Mods]]''. | |||
This $function is new in Version 6.8 of the ''[[Sirius Mods]]''. | |||
<p> | |||
<ul class="smallAndTightList"> | <ul class="smallAndTightList"> | ||
<li>[[Sirius functions]]</li> | <li>[[Sirius functions]]</li> | ||
Line 49: | Line 49: | ||
<li>[[Japanese functions]]</li> | <li>[[Japanese functions]]</li> | ||
<li>[[Sir2000 Field Migration Facility]]</li> | <li>[[Sir2000 Field Migration Facility]]</li> | ||
</ul> | |||
</ul> | |||
</p> | </p> | ||
<p class="caption">Products authorizing $Lstr_X2C | <p class="caption">Products authorizing $Lstr_X2C | ||
</p> | </p> | ||
[[Category:$Functions|$Lstr_X2C]] | [[Category:$Functions|$Lstr_X2C]] |
Revision as of 14:40, 11 February 2011
<section begin="desc" />Convert from hexadecimal to byte string<section end="desc" />
Most Sirius $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for the $Lstr_X2C function is the HexToString (String function).
This function converts from a hexadecimal encoded string to the decoded byte string. It is identical to $X2C (see the "Model 204 User Language Manual"), except it is longstring capable.
The $Lstr_X2C function accepts one argument and returns a string result whose hexadecimal encoding is that argument.
The first argument is a longstring which is a hexadecimal encoding.
The returned value is the hexadecimal decoding of the argument string. If the argument is not a valid hexadecimal encoding, the null string is returned.
Syntax
<section begin="syntax" /> %DECODED = $Lstr_X2C(string) <section end="syntax" />
For example, the following code
PRINT $Lstr_X2C('D985844099A494')
would print Red rum, which is the character representation of the EBCDIC characters represented in hexadecimal as "D985844099A494".
You can check for an invalid hexadecimal encoding by checking for the null string return value from $Lstr_X2C. Of course, if it is possible that the argument is null, the null string is a valid returned value. If you need to check for errors, and the null string is a possible argument value, you can use an approach such as the following:
%STR = $Lstr_X2C(%IN) IF %STR EQ IF %IN NE THEN error code ... END IF END IF
$Lstr_C2X is the inverse of $Lstr_X2C.
This $function is new in Version 6.8 of the Sirius Mods.