Topic: APLX Help : Help on APL language : System Commands : )COPY Copy workspace
[ Previous | Next | Contents | Index | APL Home ]

)COPY (lib) name (:pass) (name(s)

Copies into the currently-active workspace named items from a saved workspace. For example, to copy functions FRED and JOE from a workspace called MYWS in library 3, you would enter:

             )COPY 3 MYWS FRED JOE
       SAVED  1991-06-13 23.24.06

If just the workspace name is used, the entire contents are copied:

             )COPY MYWS
        SAVED  1991-06-13 23.28.17

If the name of an object to be copied matches the name of an object already in the active workspace, the copy will overwrite the object already in the workspace. See also )PCOPY Protected copy, )SCOPY Silent copy, )SPCOPY Silent protected copy). If a WORKSPACE FULL or SYMBOL TABLE FULL error is encountered, the active workspace is left unchanged. You should note that the )COPY operation works by temporarily )SAVEing the active workspace in the logical unit from which objects are being copied (or in a disc defined for temporary objects), extracting the required objects from the workspace identified in the )COPY command and then merging the active workspace and the objects to be copied. It is thus possible to see a DISC FULL message during a copy operation.

Copying classes and objects

)COPY can be used to copy classes and objects from a saved workspace. However, some special considerations arise:

  • If a class is copied, and in the original workspace it had a parent, then the )COPY will fail unless a parent class of the same name exists in the destination workspace, or is copied at the same time. APLX will report an error "Class XXX not copied, missing parent class YYY"
  • If a variable containing an object reference is copied, APLX will attempt to copy both the object reference, and the object itself together with its saved property values. However, a class of the same name as that of the original object must exist in the destination workspace (or be copied in at the same time). If this is not the case, the )COPY will proceed, but the object reference will be set to refer to the Null object. APLX will print a warning "At least one object reference set to NULL (class does not exist)".
  • When an object instance is copied in, it is possible for data to be lost. This will happen if the original version of the object (in the saved workspace) had a non-default property which is no longer valid in the current destination workspace (because the version of the class is different). If this happens, the )COPY will proceed, but APLX will print a warning "At least one object property not copied (not valid for class)".

If you )COPY a list of classes and/or objects, or an entire workspace, APLX will first copy any top-level classes (classes with no parent), then classes of the first generation (children of top-level classes), and so on. It will then )COPY object instances and other items. This guarantees that no object properties or class hierarchy information is unnecessarily lost.

Library specification and path names

There are two different ways in which you can specify where APLX should look for the saved workspace:

  • You can specify the workspace name as just the base name of the workspace, for example MYWS or Budget03, optionally preceded by a library number. In this case, APLX appends any default file-extension to the name (.aws for Windows, AIX or Linux), and searches in the directory corresponding to the specified library number. Library numbers 0 to 9 are set up either using the Preferences dialog, or by using the ⎕MOUNT system function. Library 10 contains the utility and demonstration workspaces supplied with APLX. If you omit the library number, library 0 is assumed.
  • You can specify a full operating-system path name, including directory separation characters, such as /usr/workspaces/ (Linux), C:\workspaces\ (Windows), or MacHD::workspaces:Budget03 (MacOS). APLX uses the path name exactly as supplied, so under Linux, Windows and AIX you usually need to provide the .aws file extension.

See the description of the )LOAD system command for more detail on libraries and path names.

Indirect copy

If one or more of the names following the )COPY command is enclosed in parentheses and is the name of a variable in the workspace to be copied from which is a simple character scalar, vector or matrix, then the contents of the variable are interpreted as the name or names of objects to be copied. The alternative forms of )COPY (i.e. )PCOPY, )SCOPY, and )SPCOPY) will also accept name arrays as part of the name list of the command.

             (THIS THAT THE_OTHER)←⊂'DATA'
             )WSID TEST
       WAS TEST
       NAMES   THAT    THE_OTHER       THIS
       1991-06-13 19.14.26 TEST
       CLEAR WS
             )COPY TEST (NAMES)
       SAVED  1991-06-13 19.14.26
       THAT    THE_OTHER       THIS

Topic: APLX Help : Help on APL language : System Commands : )COPY Copy workspace
[ Previous | Next | Contents | Index | APL Home ]