COPY

Syntax

COPY file1 TO file2 or

COPY [file] [TO file2] (Toolkit II) or

COPY file1 [,file2 [,file3…]] {TO | !} fileb (THOR XVI)

Location

QL ROM, Toolkit II, THOR XVI

The command COPY duplicates file1, so that file2 is an exact copy. The parameters can also be a device (eg. ser1, con, scr, scr_400x20) or, if you have Toolkit II installed, a channel (eg. #3) can be used for the second parameter.

If Toolkit II is present, COPY supports the default devices and sub-directories. COPY will look for the file to be copied on the default data device if necessary (see DATAD$).

The rules for determining the destination parameter can be somewhat complex under Toolkit II:

(1) If no device is given, but a filename is specified, then Toolkit II looks at the first parameter. The destination device is then assumed to be the same as the source device (ie. the device name specified as part of the first parameter, or the default data device - see DATAD$).

Under SMS, it will use the default data device whether or not the first parameter contains a device.

(2) If the second parameter is omitted, then again Toolkit II looks at the first parameter. The same filename as for the first parameter will be used. If a device is given in the first parameter, then this is used as the destination device (unfortunately meaning that Toolkit II tries to copy the file onto itself!). On the other hand, if no device was specified, then the default destination device will be used (see DESTD$).

Under SMS, if a device is specified in the first parameter, SMSQ/E (v2.85 at least) tries to copy the file to the default destination device without a filename! Normally unless the default destination device is either PAR or SER, this will report an error ‘is in use’.

(3) If a second parameter is given which includes a device name, then this is used!

If the destination is an existing file, unlike the normal ROM COPY command, Toolkit II will not break COPY with the error -8 (already exists), but instead it will print: >file<exists, OK to overwrite..Y or N? in channel #0 and wait for the user to press either <Y> or <N> - <ESC> and <CTRL><SPACE> mean <N> here.

Examples

Assuming that the default data device is flp1_ and the default destination device is ram2_ (using Toolkit II or SMS implementation):

Command

Effect

COPY mdv1_quill TO flp1_quill

Copies mdv1_quill to flp1_quill

COPY ram1_prog_bas, ram2_tmp

Copies ram1_prog_bas to ram2_tmp

COPY ram1_prog_bas, scr_200x100

Copies ram1_prog_bas to a window

COPY prog_bas, ser1

Copies flp1_prog_bas to ser1

COPY ser2 TO ram1_prog_bas

Copies data from ser2 to a file

COPY con TO ser

Copies everything typed to ser1

COPY ram1_prog_bas

Tries to copy ram1_prog_bas to itself unless on SMS

COPY ram1_prog_bas

Tries to copy ram1_prog_bas to ram2_ and will report an error

COPY prog_bas

Copies flp1_prog_bas to ram2_prog_bas

COPY ram1_prog_bas TO #2

Copies ram1_prog_bas to a channel

NOTE 1

The TO separator can be replaced by a comma ‘,’ (although note the THOR XVI variant!).

NOTE 2

Each file includes a file header of 64 bytes to store supple-mentary information such as the time of the last update, file type, length and much more. Without Toolkit II, COPY will always copy the header if a file is copied. The Toolkit II COPY command does not copy the header to serial devices (eg. ser) if this is specified as the destination.

NOTE 3

COPY without any parameters is allowed with Toolkit II, but it can cause problems (at least in versions up to v2.28 Toolkit II and v2.85 SMS)

As an exception to rule 2, when first used it would appear to try to copy the file “” on DATAD$ onto itself. On systems without level-2 drivers, such files can exist, but have no special function, whereas on level-2 drivers, these files contain the sub-directories. Thus, with the standard combination of Toolkit II and level-2 drivers installed, a pure COPY normally breaks with error -9 (in use) (see FMAKE_DIR for the reason).

However, due to a bug in current versions of Toolkit II, when first used it may report error -15 (bad parameter), in which case it will have left the file flp1_ open and prevent most of any further access to that device (unless you can close the channel with CLOSE% or a desktop).

NOTE 4

On SMS pre v2.58, if you used COPY and were asked if you wanted to overwrite the file, and answered N, an error code was returned.

THOR XVI NOTES

The THOR XVI (v6.41 and later) supports the third variant of COPY. This allows you to merge several files:

COPY flp1_texta,flp1_textb TO flp2_Book will create a new file flp2_Book made up of the merged files flp1_texta and flp1_textb. The headers will (of course) not be copied.

If you alter the TO delimiter to !, ie: COPY flp1_texta,flp1_textb ! flp2_Book

then it is assumed that fileb already exists and file1, file2 and file3 are all appended to it.

CROSS-REFERENCE

SPL_USE and DEST_USE set the destination device.

See COPY_N and COPY_H for copying file headers and COPY_O on how to force overwriting.

SPL performs a background copy (ie. it multitasks).

See APPEND which is similar to the THOR variant.