The ChgUsrSpace procedure changes data in a *USRSPC (user space) object.
The ChgUsrSpace procedure can be used to change the data in an existing user space object. The substring parameters allow the entire user space to be changed or only a portion to be changed.
user-space-data ChgUsrSpace( szUserSpace 21A Const nStart 10I 0 Const OPTIONS(*OMIT) nLength 10I 0 Const OPTIONS(*OMIT) szData 32766A Const VARYING ) |
|
See also: CrtUsrSpace, DltUsrSpace |
*...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.
If the user space is changed, *ON is returned, otherwise *OFF is returned.
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 changed.
Use caution when calling this procedure without a second or third parameter. The following statement, for example, will cause the entire user space to be cleared.
C callp ChgUsrSpace(szUS : *OMIT : *OMIT : ' ')
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; far surpassing the maximum length of a data area.
.....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 example calls the ChgUsrSpace() procedure to change the first 7 bytes of the user space named CONTROLS in the QGPL library.