The CpyUsrSpace procedure copies the data from one user space to another.
The CpyUsrSpace procedure can be used to copy the data from an existing user space object to a second user space. If the target user space does not exist, it is created.
user-space-data CpyUsrSpace( szFromUserSpace 21A Const szToUserSpace 21A Const bReplace 1N Const OPTIONS(*NOPASS) nBytes 10I 0 Const OPTIONS(*NOPASS) ) |
|
See also: CrtUsrSpace, DltUsrSpace |
*...v....1....v....2
'MYSPACE QTEMP '
An alternative, and preferred syntax is also supported for user space names. This syntax allows you to specify the user space name similar to that of an OS/400 CL command, that is it may be specified using qualified name syntax, as follows:
*...v....1....v....2
'QTEMP/MYSPACE '
The qualified user space name in the above example is MYSPACE in the QTEMP library. Both syntax styles are supported.
If the copy is successful, the number of bytes copied is returned.
If the function fails, 0 is returned.
This procedure, by default, replaces the existing user space. If the user space already exists, it is cleared by setting its current size to zero and the the copy is performed. The ibute should be set on the target user space (its size set to zero). If the target user space does not exist, it is created using the default settings of the CrtUsrSpace procedure.
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 szMyUS C Const('CONTROLS QGPL')
.....CSRn01..............OpCode(ex)Extended-factor2++++++++++++++++++++++++++++++
C callp CpyUsrSpace(szMyUS : 'qtemp/backupUS')
This example calls the CpyUsrSpace() procedure to copy the user space named CONTROLS in QGPL to the user space named BACKUPUS in QTEMP.