PreviousNextIndex

PUT-BYTE statement

Stores the unsigned 1-byte value of an integer expression at the specified memory location.

Syntax

PUT-BYTE ( destination , position ) = expression 

destination
position
expression
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. 
ASSIGN 
  r1                 = RAW(Customer.Name) 
  PUT-BYTE(r1,1)     = ASC(’B’) 
  PUT-BYTE(r1,2)     = ASC(’i’) 
  PUT-BYTE(r1,3)     = ASC(’l’) 
  PUT-BYTE(r1,4)     = ASC(’l’) 
  RAW(Customer.Name) = r1. 
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.

r-mptput.p
DEFINE VARIABLE mptr AS MEMPTR NO-UNDO. 
ASSIGN 
  SET-SIZE(mptr)   = LENGTH("Bill") + 1 
  PUT-BYTE(mptr,1) = ASC(’B’) 
  PUT-BYTE(mptr,2) = ASC(’i’) 
  PUT-BYTE(mptr,3) = ASC(’l’) 
  PUT-BYTE(mptr,4) = ASC(’l’) 
  PUT-BYTE(mptr,5) = 0. 
DISPLAY GET-STRING(mptr,1). 

Note

For more information on accessing DLL routines from ABL, see OpenEdge Development: Programming Interfaces.

See also

GET-BYTE function, LENGTH function, LENGTH statement, RAW function, RAW statement, SET-SIZE statement


OpenEdge Release 10.2B
Copyright © 2009 Progress Software Corporation
PreviousNextIndex