Progress
Language Reference


PUT-BYTE Statement

Interfaces
OS
SpeedScript
All
All
Yes

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

SYNTAX

PUT-BYTE ( destination , position ) = expression 

destination

A variable of type RAW or MEMPTR. If destination is the unknown value (?), it remains the unknown value. If destination is a MEMPTR and has not had its region allocated (by a SET-SIZE statement or by a Windows dynamic link library (DLL) or UNIX shared library routine), Progress generates a run-time error.

position

An INTEGER value greater than 0 that indicates the byte position where Progress stores expression. If position is less than 1, Progress generates a run-time error. For a RAW destination, if position is greater than the length of destination, Progress changes the length of destination to position and pads the gap with null bytes. For a MEMPTR destination, if position is greater than the length of destination, Progress generates a run-time error.

expression

The INTEGER value of a constant, field, variable, function, or expression. If expression is less than 0 or greater than 255, Progress stores the right-most byte value of expression in destination.

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-PROGRESS demo database to run
   this procedure */

DEFINE VARIABLE r1 AS RAW.

FIND customer WHERE cust-num = 26.
DISPLAY name.
r1 = RAW(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(name) = r1.
DISPLAY 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.

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 Progress, see the Progress External Program Interfaces manual.

SEE ALSO

GET-BYTE Function, LENGTH Function, LENGTH Statement (ORACLE only), 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