Chapter Contents

Previous

Next
Command Directory

copy

Copy One or More Items to a New Location

ABBREVIATION
co{py}

FORMATS

Format 1: copy
DESTINATION, "STRING"
Format 2: copy
DESTINATION, "STRING", BYTES
Format 3: copy
DESTINATION, [(CTYPE1 | CTYPE2)] SOURCE [,COUNT]
Format 4: copy
DESTINATION, SOURCE, str
Format 5: copy
DESTINATION, [(CTYPE2)] {LIST}

DESCRIPTION
The copy command copies items from one location to another. The copy command is used to copy a string, address, array, pointer, or one or more expressions to a location. STRING is a string literal, set off by double quotation marks. DESTINATION is a pointer, address, or array name. In the following format discussions, SOURCE and DESTINATION are expressions.

Format 1: Format 1, similar to the strcpy function, copies a string literal specified by the STRING argument to the location specified by the DESTINATION expression. A comma must follow the DESTINATION argument.

Format 2: Format 2, similar to the memcpy function, copies a string literal. The string literal to be copied is specified in the STRING argument (set off by double quotes). BYTES is an integer that indicates the number of bytes to be copied to the location specified by the DESTINATION expression.

Format 3: Format 3 copies the item or items specified by the SOURCE expression to the DESTINATION expression. DESTINATION and SOURCE can be pointers, addresses, or arrays. COUNT, an integer, is the number of items to be copied. If COUNT is omitted, the number of items defaults to 1. Each item is the size specified by either CTYPE1 or CTYPE2.

CTYPE1
is a structure/union tag or a type defined with a typedef function.

CTYPE2
is one of the following arithmetic types:
   long    signed long    unsigned long    double
   int     signed int     unsigned int     float
   short   signed short   unsigned short   enum
   char    signed char    unsigned char

If you use a left parenthesis following the DESTINATION argument, the debugger assumes that you are beginning a CTYPE1 or CTYPE2 specification.

The result of using Format 3 is analogous to the following:

memcpy(DESTINATION,SOURCE,((sizeof (CTYPE1 or CTYPE2)) * COUNT)

Note that if you omit the CTYPE1 or CTYPE2 argument, the sizes of the expressions that SOURCE and DESTINATION point to must be the same. If the sizes are not the same, you receive a message, and the copy command is not performed.

CTYPE1 overrides the declared types of both the DESTINATION and SOURCE arguments. If the SOURCE or DESTINATION argument does not have a specific type, the type defaults to char . For absolute addresses, the default type is char and the size of the pointed-to expression is 1.

Format 4: Format 4 copies the contents of a memory location pointed to by SOURCE to the location specified by the DESTINATION expression until the null terminator \ 0 is encountered in the SOURCE expression. The keyword str specifies a string copy that is similar to strcpy . SOURCE is a pointer, address, or array. The string delimiter \ 0 is the last byte copied.

If the SOURCE argument begins with a left parenthesis, the parenthesis must be escaped with a backslash (\). If you do not escape the parenthesis, the parenthesis is assumed to begin a CTYPEx. Here is an example:

copy a+5, \ (b+2)

Format 5: Format 5 converts the items specified by LIST to CTYPE2 format and stores the values at the destination specified by the DESTINATION expression. LIST is one or more expressions. (If you use more than one, separate them with commas.)

DESTINATION is a pointer, address, or array name. CTYPE2 is any of the arithmetic types, as listed for Format 4. If you do not specify CTYPE2, the type of the object pointed to by the DESTINATION expression is the default.

EXAMPLES
The copy command examples are based on the following declarations:
   char *cp, *s, *d;
   struct XYZ {int a; double b;} xyz, xarr[5] , yarr[5] ;
   int intarr[5] ;

copy cp, "abcd"
copies the string abcd to the location pointed to by cp .

copy cp, "abcd", 4
copies 4 bytes ( abcd ) into the location pointed to by cp (the null terminator \ 0 is not copied).

copy xarr, yarr, 5
copies the five elements of the array yarr into the array xarr .

copy &xyz, &xarr[2]
copies xarr[2] into xyz.

copy d, s, 10
copies 10 bytes from the location pointed to by s to the location pointed to by d .

copy d, s, str
copies the string pointed to by s into d .

copy intarr (int) {10,20,30,40,50}
copies the values 10, 20, 30, 40, 50 as integers into the array intarr .

SYSTEM DEPENDENCIES
none

COMMAND CAN BE ISSUED FROM

PROFILE no
configuration file no
Source window prefix none

SCOPE
The copy command uses command scope to resolve references to all identifiers.

RETURN CODES SET
Successful: 0
Unsuccessful: 1

SEE ALSO


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.