Release 10.1A: OpenEdge Development:
Progress 4GL Reference

> ## GET-BYTE function

> 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-OpenEdge 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

> - For more information on using the MEMPTR data type, see OpenEdge Development: Programming Interfaces .

> - For more information on using the RAW data type, see OpenEdge Development: Programming Interfaces .

> - You can use the alternative keyword GETBYTE instead of GET-BYTE.

> #### See also

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

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