Byte PowerScript function
Description
Converts a number into a Byte datatype
or obtains a Byte value stored in a blob.
Syntax
|
1 |
<span>Byte</span> ( <span>stringorblob</span> ) |
|
Argument |
Description |
|---|---|
|
stringorblob |
A String or any |
Return Values
Byte. Returns the value of the stringorblob variable
as a Byte datatype if it succeeds; it returns
0 if the stringorblob variable is not a valid
PowerScript number or if it has an incompatible datatype. If stringorblob is null, Byte returns null.
Usage
If the number you convert exceeds the upper range of the Byte
datatype (>255), the Byte method returns
the difference between the number you pass in the stringorblob argument
and the nearest multiple of 256 below that number.
If you pass a blob in the stringorblob argument,
only the value of the initial character is converted to a byte value.
(There is no “overflow” when you use a blob argument.)
To get the byte value for a character at a different position in the
blob, you can use the GetByte method.
Examples
This example converts a string entered in a SingleLineEdit
control to a byte value:
|
1 |
Byte ly_byte |
|
1 |
ly_byte = <span>Byte</span>(sle_1.text) |
If the text entered in the SingleLineEdit is 4, the byte value
of ly_byte is 4. If the text entered
is 257, the value of ly_byte is 1.
For 256 or text such as “ABC12”, the value of
ly_byte is 0.
This example returns the ASCII value of the initial
character that you enter in a SingleLineEdit control:
|
1 |
Byte lb_byte |
|
1 |
Blob myBlob |
|
1 |
myBlob = Blob(sle_1.text) |
|
1 |
lb_byte = <span>Byte</span>(myBlob) |