Assignment Statements

The assignment statement takes the general form:

LHS = expression ;

expression (RHS, right-hand side) is evaluated and put into LHS (left-hand side). If LHS does not exist, it is created if possible, otherwise an error will be reported.

When a new data object is created with an assignment statement without declaration

Object Type Description Example
string variable LHS ends with a $ and right side evaluates to a string name$=page.name$; fpath$=%Y;
numeric variable LHS not ending with $ and right side expression evaluates to a scalar min=0.5; max=min+100; size=wks.nrows;
dataset variable LHS not ending with $ and right side expression evaluates to be a range ds1=col(A); ds2={1.2, 3.4, 5.6}; ds3=ds2;
unresvered string register LHS starts with % with one letter not reserved as system variables  %A = "Hello World";

When new values are assigned to an existing data object, the following conventions apply:

LHS RHS Description Example
dataset/range variable scalar expression Every value in 'LHS dataset will be set to the expression
col(A)=3; //every value of col(A) set to 3
Book1_B=100; //every value of column B in Book1 set to 100
dataset/range variable dataset/range expression Assign each value on RHS expression to the corresponding value of LHS variable
col(C) = col(B)*2.5; //column B times 2.5 and assign to column C
numeric variable dataset/range variable or expression Assign the 1st value of dataset/range to LHS variable
ds1={1.2, 3.4, 5.6}; //create a dataset
begin=ds1; //assign 1st value in ds1 to begin
string variable expression RHS will be assumed to be string expression even without " "
name$=Amplitude; //name$ will be assigned to "Amplitude"
fn$=system.path.program$ + "Samples\Spectroscopy\HiddenPeaks.dat";
object.property expression Set object's numeric or string property
wks.ncols=5; //set number of columns in worksheet to 5
wks.name$=MyInput; //set current sheet name to "MyInput"
Book1!wks.rhw=100; doc -uw; //set row header height to 100 and refresh.
unresvered string register string expression Evaluate expression and assign to the string register
%A = "%YTest.opju" concatenate %Y and Test.opju and assign to %A 

Note: If a string register to the left of the assignment operator is enclosed in parentheses, the string register is substitution processed before assignment. For example:

ds={1.2, 2.3, 3.4};
(ds)=2*%B; //ds times 2 and put back to ds, '''%B''' still holds the string "ds".
type $(ds); //will output new ds values 2.4 4.6 6.8