Get User Space Attributes

GetUsrSpaceA

The GetUsrSpaceA procedure retrieves a specific attribute for a user space (*USRSPC) object.

The GetUsrSpaceA procedure can be used to retrieve the size, initial character, and auto-extend attribute for a user space object.

user-space-attr (int4)  GetUsrSpaceA(
 szUserSpace    21A    Const
 nAttribute     10I 0  Const OPTIONS(*NOPASS)
)

See also: CrtUsrSpace, RtvUsrSpaceA

Parameters

szUserSpace
[input Char(21) const]  User Space name. This parameter consists of two parts (1) in the first 10 positions, the name of the user space, and (2) in the second 10 positions, the name of the library containing the user space For example:
 
 *...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.

 
nAttribute  [optional DFT(1)
[input Int(4) const]  An identifier that indicates which user space attribute to return. The permissible values are as follows:

Return Value

The user space attribute is returned as a 4-byte binary (Int4 or 10i0) value.

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.

Example

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 = GetUsrSpaceA(szUS:1:7)
     C                   eval      nNextCust = CharToNum(szNextCust) + 1
     C                   callp     ChgUsrSpace(szUS:1:7 : %EditC(nNextCust:'X'))

This call to GetUsrSpaceA() 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.