Copying codes
Quick reference
To copy codes into a single data variable, overwriting the variable’s original contents, type:
variable='codes'
To copy a string of codes into a field, type:
var_name(start,end)=$codes$
To copy the contents of one variable or field into another, type:
variable1 = variable2
More information
Assignment statements are most commonly used to copy codes into a column or to copy the contents of one variable into another. For example:
c121='159'
This example copies the codes 1, 5 and 9 into column 121 overwriting whatever is already there.
c121=c134
This example copies everything in column 134 into column 121, again overwriting what was originally there. Column 134 remains unchanged.
You can also copy strings of characters into fields of columns. For example, to copy the code 59642 into columns 76 to 80 of card 3, write:
c(376,380)=$59642$
The characters to be copied into the array are enclosed in dollar signs as is the rule when dealing with strings.
To use a semicolon in a string, type it as:
\;
Quantum uses a semicolon to mark the end of a statement, and issues an error message if it finds a semicolon by itself in the middle of a string. The backslash in front of the semicolon tells Quantum to read the next character as an ordinary character with no special meaning. For example:
c(376,380)=$59\;42$
inserts 59 in c(376,377), a semicolon in column 378, and 42 in c(379,380).
When characters are being copied into columns, the equals sign can be omitted:
c10'4' | is the same as | c10='4' |
c(11,14)$6353$ | is the same as | c(11,14)=$6353$ |
Just as the contents of a single column can be copied into another, so the contents of one field can be copied into another field. For example:
c(10,19)=c(70,79) | or | c(20,22)=c(45,47) |
copies the contents of c(70,79) into c(10,19) and the contents of c(45,47) into c(20,22), in both cases overwriting the original contents of those columns.
Data variables in assignment statements can be subscripted. The following are valid:
c(t1)=c145
c(178,180)=c(t4,t5)
c(t3,t5)=c(t10,t10+2)
The equals sign in these kinds of operation can not be omitted.
When subscripting columns, remember that the current values of the integer variables is substituted in the expression before the statement itself is executed. If t3=120 and t10=240, the statement:
c(t3,t3+2)=c(t10,t10+2)
means:
c(120,122)=c(240,242)
Generally, you will know how many characters are required to hold the information they will receive, but this is not always the case. What if the field on the left of the equals sign is longer than the string to be copied into it? Quantum always copies a string starting with the right-most column and transferring it into the rightmost column of the field. It continues in this way until all characters have been copied, then if there are still columns left in the field they are reset to blanks. When strings are copied in this way they are called ‘right-justified and blank-padded’.
Example 1
Suppose you have:
----+----9--- ... ---4----+----5
100 84635
and you enter:
c(241,245)=c(185,187)
You then have:
----+----9--- ... ---4----+----5
100 100
If there are fewer characters than there are columns in the field, the characters are right-justified in the field with the remaining columns set to blanks. If the reverse is true, and there are more characters than there are columns in the field, the error message ‘Attempt to set too many columns into too few columns’ is issued.
Example 2
Columns in assignment statements can overlap; for example:
c(145,150)=c(143,148)
copies the contents of columns 143 to 148 into columns 145 to 150, so:
----+----5 ----+----5
83645902 becomes 83836459
When a field is set to blanks it is never wrong to type in as many blanks (enclosed in dollar signs) as there are columns in the field, but it is much quicker and more efficient to type, say:
c(301,380)=$ $
See also