|
|||||||||
|
|||||||||
Related Syntax | Related Concepts | ||||||||
action | copy |
Syntax
copy shelf-name to shelf-name
You can use copy
to copy the entire contents of one shelf to another. The contents of the destination shelf are removed and replaced with the contents of the source shelf.
Both the source and destination shelves must be of the same data type. Because the destination shelf will become the same size as the source shelf, it must be either variable
size or the same size as the source shelf. If the destination shelf was declared variable with a maximum size, the maximum size must be equal to or greater than the current size of the source shelf.
When stream shelves are copied, all streams on the source shelf must be either closed and attached to buffers or unattached. All open streams on the destination shelf will automatically be closed before the copy
action takes place.
This code fragment illustrates how copy
can be used to copy the contents of one shelf into another.
This example copies all the items of the integer shelf "reference-counts" to "saved-reference-counts". After the copy, "saved-reference-counts" has the same number of items as "reference-counts", and each item in "saved-reference-counts" has the same value and key as its corresponding item in "reference-counts".
global integer reference-counts process local integer saved-reference-counts copy reference-counts to saved-reference-counts
You can copy the contents of a shelf and clear the source shelf in a a single action using copy-clear
. This action has the advantage that it allows you to copy open shelves and shelves with external attachments.
Related Syntax copy-clear |
Related Concepts Shelves |
---- |