The GetUsrSpace procedure retrieves data from a *USRSPC (user space) object.
The GetUsrSpace procedure can be used to retrieve data from an existing user space object. The start and length parameters allow a portion of the user space or the entire user space (up to the RPG field size limitation).
user-space-data GetUsrSpace( szUserSpace 21A Const nStart 10I 0 Const OPTIONS(*NOPASS) nLength 10I 0 Const OPTIONS(*NOPASS) ) |
|
See also: CrtUsrSpace, ChgUsrSpace |
*...v....1....v....2
'MYSPACE QTEMP '
An alternative syntax is also supported for the user space parameter. The alternate syntax allows you to specify the user space name similar to that of an OS/400 CL command, that is it may be qualified using qualified name syntax, as follows:
*...v....1....v....2
'QTEMP/MYSPACE '
The qualified user space name is MYSPACE in the QTEMP library. Either syntax is acceptable.
The data from the user space is returned. It may be assigned to a variable using the EVAL operation or used in a conditional statement.
If the function fails, check the XT_ERROR data structure's subfield XT_ERRMSGID for the error message ID indicating why the user space was not created.
A user space may be used in place of a data area or a "control" file. A user space may be up to 16 megabytes in length whereas a data area may up to 2000 in length.
.....DName+++++++++++EUDS.......Length+TDc.Functions++++++++++++++++++++++++++
D szUS C Const('CONTROLS QGPL')
D szNextCust S 7A
D nNextCust S 7P 0
.....CSRn01..............OpCode(ex)Extended-factor2+++++++++++++++++++++++++++
C eval szNextCust = GetUsrSpace(szUS:1:7)
C eval nNextCust = CharToNum(szNextCust) + 1
C callp ChgUsrSpace(szUS:1:7 : %EditC(nNextCust:'X'))
This call to GetUsrSpace() retrieves the first 7 bytes of the user space named CONTROLS in the QGPL library. The second line of code converts that value to numeric and assigns it to the numeric field named nNextCust. Then the user space is updated with the new value.