Progress
Language Reference


GET-BYTE Function

Interfaces
OS
SpeedScript
All
All
Yes

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

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, Progress returns the unknown value (?). If position is less than 1, Progress generates a run-time error.

EXAMPLES

In this example, the RAW Function goes to the customer field in the non-Progress database. The GET-BYTE function accesses the first byte and stores the integer value of that byte in the variable i. The procedure then tests the value, if the integer value is 83 (the character code value for S), Progress displays the name.

r-rawget.p
/*You must connect to a non-PROGRESS database to run this procedure*/

DEFINE VARIABLE i AS INTEGER.

FOR EACH customer:
  i = GET-BYTE(RAW(name),1).
  IF i = 83
  THEN DISPLAY 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.
DEFINE VARIABLE cnt  AS INTEGER.

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 (ORACLE only), RAW Statement (ORACLE only), SET-SIZE Statement


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095