Manipulate a user space without pointers

When programming in a language that does not support pointers, you can use the Change user space (QUSCHGUS) and Retrieve user space (QUSRTVUS) APIs to manipulate data. However, you must first understand how to use positions and lengths with these APIs.

Position values

Some APIs return offset values into a user space. To use other APIs, such as the Retrieve user space (QUSRTVUS) API, you must use position values to locate bytes.

Position values and offset values are different ways to express the same thing. An offset value is the relative distance of a byte from the first byte of the user space, which has an offset value of 0. A position value is the offset value plus 1.

For examples of HLL programs that use positions, see Example in RPG: List Object API.

Lengths

List APIs return the length of the information in the different sections of the user space, as well as the length of the list entries in the user space. You should code your application using the lengths returned instead of specifying the current length returned by the API or the size of a data structure in the data structure files. The amount of information returned for any format may increase in future releases, but the information will be placed at the end of the existing information. In order for your application to function properly, it should retrieve the length of the information returned and add that length to a pointer or to a starting position.

Using offset values with the change and retrieve user space APIs

When you use the Change User Space (QUSCHGUS) or Retrieve User Space (QUSRTVUS) API, your application program should first retrieve the offset value for the information you want. You must then add one to the offset value to get the starting position for the information.

Related reference
Example in RPG: List Object API