Previous Next

GET-BYTE function
Returns the unsigned 1 byte value at the specified memory location as an INTEGER value.
Syntax 
 
GET-BYTE ( source , position )
source
A function or variable that returns a RAW or MEMPTR value. If source is the Unknown value (?), GET-BYTE returns the Unknown value (?).
position
An integer value greater than 0 that indicates the byte position where you want to find the information. If position is greater than the length of source, the AVM returns the Unknown value (?). If position is less than 1, the AVM generates a run-time error.
Examples 
In this example, the RAW function goes to the Customer field in the non-OpenEdge database. The GET-BYTE function accesses the first byte and stores the integer value of that byte in the variable ix. The procedure then tests the value, if the integer value is 83 (the character code value for S), the AVM displays the Customer Name.
 
/* You must connect to a non-OpenEdge database to run this procedure */
DEFINE VARIABLE ix AS INTEGER NO-UNDO.
 
FOR EACH Customer:
  ix = GET-BYTE(RAW(Customer.Name), 1).
  IF ix = 83 THEN
    DISPLAY Customer.Name.
END.
The next procedure sets up a MEMPTR region with a character string and uses the GET-BYTE function to display the character code value of each character in the string:
 
DEFINE VARIABLE mptr AS MEMPTR  NO-UNDO.
DEFINE VARIABLE cnt  AS INTEGER NO-UNDO.
 
ASSIGN
  SET-SIZE(mptr)      = LENGTH("DANIEL") + 1
  PUT-STRING(mptr, 1) = "DANIEL".
 
REPEAT cnt = 1 TO LENGTH("DANIEL"):
  DISPLAY GET-BYTE(mptr, cnt).
END.
Notes 
*
For more information on using the MEMPTR and RAW data types, see OpenEdge Development: Programming Interfaces.
*
See also 
LENGTH function, PUT-BYTE statement, RAW function, RAW statement, SET-SIZE statement

Previous Next
© 2013 Progress Software Corporation and/or its subsidiaries or affiliates.