OriginPro 2015
Windows 10
Hi,
I'm running an ogs script after a file import via the run command in the Import Wizard.
In the first lines, a StringArray is created, give some values (Sample 1, Sample 2, etc.), then ask for the real sample names:
//Declare variables to be used
bookname$ = "DLS";
wksname$ = layer.name$;
axislang$ = "English";
xname$ = "Size";
yname$ = "Intensity";
y2name$ = "Volume";
y3name$ = "Number";
samples = 1;
reads = 3;
//Creates Samples name Array
StringArray names;
names.Add("Sample 1"); //Add temporary data
//Use GetN dialog to collect data
getn (Samples) samples (Reads per sample) reads (Workbook name) bookname$ (Axis Language) axislang$ (DLS Import);
//Ask for each Sample Name
names.SetSize(samples); //Set StringArray size to samples quantity
//Add "Sample 1", "Sample 2", etc to show in getn dialog
loop(ii,1,samples){
names.SetAt(ii, "Sample $(ii)")
}
//Ask user to input sample name
loop(ii,1,samples){
samplename$ = names.GetAt(ii)$;//temporary var to store sample name
getn (Sample $(ii) Name) samplename$ (Input Sample Names);
names.SetAt(ii,samplename$);//store sample name to stringarray
}
The problem is that the StringArray isn't created.
If before running the script I create the StringArray in the command window, the script runs perfectly. Otherwise, it gives a lot of errors because de string array wasn't created. After running the script, I can create the array and run the script again and it will run fine. It doesn't matter if I ran the script or not, I must create the array in the command window in order for the script to run.
If copy and paste the above script in the command window, it runs fine. However, if the script is exec from the run command, it gives error.
After run in command window, if I restart Origin and run the script via the Import Wizard or run command, it gives error again, because the string array wasn't created.
Why I can't create the string array inside the ogs script file?
Thank you.