Caché ObjectScript Reference
[Home] [Back] [Next]
InterSystems: The power behind what matters   
Class Reference   

Converts a four-byte string to a number.
string A string that can be specified as a value, a variable, or an expression. It must be a minimum of four bytes in length.
position Optional — A starting position in the string. The default is 1.
The value $ZLASCII returns depends on the parameters you use.
Upon successful completion, $ZLASCII always returns a positive integer. $ZLASCII returns -1 if string is of an invalid length, or position is an invalid value.
$ZLASCII is similar to $ASCII except that it operates on four byte (32-bit) words instead of single 8-bit bytes. For two byte (16-bit) words use $ZWASCII; for eight byte (64-bit) words, use $ZQASCII.
$ZLASCII(string,position) is the functional equivalent of:
$ASCII(string,position+3)*256 + $ASCII(string,position+2)*256 + $ASCII(string,position+1)*256 + $ASCII(string,position)
The $ZLCHAR function is the logical inverse of the $ZLASCII function. For example:
   SET x=$ZLASCII("abcd")
   WRITE !,x
   SET y=$ZLCHAR(x)
   WRITE !,y
Given “abcd” $ZLASCII returns 1684234849. Given 1684234849 $ZLCHAR returns “abcd”.
See Also