PreviousNextIndex

GET-BYTE function

Returns the unsigned 1 byte value at the specified memory location as an INTEGER value.

Syntax

GET-BYTE ( source , position ) 

source
position
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.

r-rawget.p
/* 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:

r-mptget.p
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
See also

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


OpenEdge Release 10.2B
Copyright © 2009 Progress Software Corporation
PreviousNextIndex