Progress
External Program
Interfaces
Reading and Writing Data
Once you have initialized a MEMPTR variable, you can build a data aggregate (structure) or access an existing structure in the associated memory region using several memory-writing statements and memory-reading functions. Memory-writing statements write values to specified locations in the memory region. Memory-reading functions return values from the specified locations in the memory region. Through an appropriate choice of these statements and functions you can thus copy Progress data types and bit fields to and from MEMPTR variables. You can also copy complete Progress database records to and from MEMPTR variables.
NOTE: Before setting or getting values in a MEMPTR variable, you might want to check the MEMPTR size using the GET-SIZE function. For more information, see the "Initializing and Uninitializing MEMPTR Variables" section.This is the syntax for the MEMPTR memory-writing statements (except PUT-STRING):
This is the syntax for the MEMPTR memory-reading functions (except GET-STRING and GET-BYTES):
Each PUT-datatype statement writes a value (expression) of a certain data type to the memory region associated with the MEMPTR variable mptr-name at the specified byte-position. Each GET-datatype function reads and returns the value of a data type from the memory region associated with the MEMPTR variable mptr-name at the specified byte-position. The byte-position in these statements and functions is specified by an integer expression that starts at one (1).
The PUT-STRING statement and GET-STRING function each allow an additional optional parameter that specifies the number of bytes to write or read in the MEMPTR variable. The GET BYTES function has the same parameter, but it is required for this function.
NOTE: The mptr-name parameter in these statements and functions can reference RAW as well as MEMPTR variables. However, the EPIs that require MEMPTR variables cannot use RAW variables directly. You must convert RAW values to MEMPTR before using them with these EPIs. You can do this using direct assignment between RAW and MEMPTR variables or by using statements and functions such as PUT-BYTES, GET-BYTES, or GET-RAW.Memory-writing Statements
Progress provides the PUT-datatype statements shown in Table 1–1.
For more information on these statements, see the Progress Language Reference .
Memory-reading Functions
Progress provides the GET-datatype functions shown in Table 1–2.
For more information on these functions, see the Progress Language Reference .
Copying Between Basic Progress Data Types and MEMPTR
Table 1–3 lists the basic Progress data types and how you can copy them in and out of a MEMPTR variable.
Table 1–3: Copying Between Basic Progress Data Types
and MEMPTR Data Type Copying To/From MEMPTR DATE To copy into a MEMPTR:To copy from a MEMPTR: DECIMAL1 To copy into a MEMPTR:To copy from a MEMPTR: INTEGER1 To copy into a MEMPTR:To copy from a MEMPTR: LOGICAL1 To copy into a MEMPTR:To copy from a MEMPTR: RAW To copy into a MEMPTR:To copy from a MEMPTR:
Manipulating Bit Values
You can copy bit values up to the size of a Progress INTEGER from one INTEGER value to another. The statement to copy bit values to an INTEGER variable, PUT-BITS, has the following syntax:
This statement interprets an integer (integer-expression) as the sequence of bits representing the binary value of integer-expression. For example, if the value of integer-expression is 22, the bit sequence is 10110. The statement interprets the INTEGER variable, destination, as a sequence of bits and writes the sequence of bits from integer-expression into destination, starting at the specified bit position (start-position) The bit position in destination is counted from the low-order bit, where the first bit is bit one (1). If the value of integer-expression is too large to store in the specified number of bits, Progress stores the low-order count bits of integer-expression in the specified count bits within destination.
The function to return some number of bits from an INTEGER variable, GET-BITS, has the following syntax:
This function returns the INTEGER that represents the value of the number of bits specified by count starting at the specified low-order bit position (start-position) within the INTEGER variable specified by source.
Thus, you can store bit values in MEMPTR variables and return bit values from MEMPTR variables by using the PUT-LONG statement and GET-LONG function to store and return the corresponding INTEGER expression that contains the bit pattern.
Copying Between Database Records and MEMPTR
Copying a database record to and from a MEMPTR variable relies on the RAW-TRANSFER statement. This statement allows you to copy a whole database record buffer to a RAW variable or to copy a RAW variable to a database record buffer.
Thus, to store a database record in a MEMPTR variable:
To retrieve a database record from a MEMPTR variable:
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |