Stores the unsigned 1-byte value of an integer expression at the specified memory location.
Syntax
PUT-BYTE ( destination , position ) = expression
destination
A variable of type RAW or MEMPTR. If destination is the Unknown value (?), it remains the Unknown value (?). If destination is a MEMPTR and has not had its region allocated (by a SET-SIZE statement or by a Windows dynamic link library (DLL) or UNIX shared library routine), the AVM generates a run-time error.
position
An integer value greater than 0 that indicates the byte position where the AVM stores expression. If position is less than 1, the AVM generates a run-time error. For a RAW destination, if position is greater than the length of destination, the AVM changes the length of destination to position and pads the gap with null bytes. For a MEMPTR destination, if position is greater than the length of destination, the AVM generates a run-time error.
expression
The integer value of a constant, field, variable, function, or expression. If expression is less than 0 or greater than 255, the AVM stores the right-most byte value of expression in destination.
Examples
This procedure finds the name of Customer 26, Jack's Jacks, and stores it in the RAW variable r1. The PUT-BYTE statement replaces the first four bytes in the Name with the specified character code values. The procedure then writes the values in r1 back into the Name field and displays that field. Jack's Jacks becomes Bill's Jacks.
r-rawput.p
/* You must connect to a non-OpenEdge demo database to run this procedure */
DEFINE VARIABLE r1 AS RAW NO-UNDO.
FIND Customer WHERE Customer.CustNum = 26.
DISPLAY Customer.Name.
The following example allocates a MEMPTR region large enough to hold the character string "Bill", terminated by a null byte. It stores the string one byte at a time using the PUT-BYTE statement, and then displays the string directly from the region.