//I have added some comments to the code for clarity.
//If any comments are misleading please correct them and repost.
// This is a comment.
/* This is a multi-line comment.
* It has two lines. */
win -a Data1; // Set Data1 as the active window.
// This also Restores the "Data1" window if it was minimized.
nR=wks.nRows; // Set variable "nR" and "nC" to the number of rows and
nC=wks.nCols; // colums (respectively) in the current worksheet
/* Loop over all rows. */
loop(ii, 1, nR) // just like for(ii=1; ii<nR; ii=ii+1)
{
%A=MyWks$(ii); // Sets string variable "%A" to "MyWks"
// with the value of ii appended to it. (i.e. MyWks1)
win -t wks origin %A; // Open a new worksheet called %A
win -a Data1; // Set Data1 as the active window.
kk=1;
/* Loop over all columns. */
for(jj=1; jj<nC; jj=jj+2)
{
// %A = worksheet
// %A_A = column A of worksheet
// %A_A[5] = 5th row element of column A of worksheet
/* col()[] is of the form: col(colName)[row#]
* col()[] returns the numeric value of the dataset item specified.
* Since no dataset is specified when we use it below, the command uses
* the dataset in the active window. We have just set the active window
* to Data1 a few commands ago.
*/
/* Now we take the data from the Data1 dataset and put it in the %A
* dataset. We do this one data element at a time.
*/
%A_A[$(kk)]=col($(jj))[$(ii)];
%A_B[$(kk)]=col($(jj+1))[$(ii)];
kk++; // same as "kk=kk+1;" which is the same as "kk+=1;"
}
%B=MyPlot$(ii); // Specify output graph name and set it to variable "%B"
win -t plot scatter %B; // Open a new scatter plot window called %B
layer -i %A_B; // Plot dataset %A_B
layer.x.from=0; // Set X-axis to start at 0
layer.x.to=100; // Set X-axis to end at 1
layer.y.from=0; // Set Y-axis to start at 0
layer.y.to=40000; // Set Y-axis to end at 1
sec -p 1; // Pause, this is necessary to wait for the graph is ready
image.filename$=d:\test\%B.gif; // Specify the output file name and path
image.export.pagepixel(gif,640,480,24,0); // Specify the output graph pixel resolution
win -cd %B; // Close the worksheet and delete all of its data.
win -cd %A; // Close the worksheet and delete all of its data.
}
Edited by - bg-phys on 07/19/2006 11:46:54 AM