T O P I C R E V I E W |
luismramirezr |
Posted - 04/10/2016 : 10:25:42 PM 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. |
2 L A T E S T R E P L I E S (Newest First) |
luismramirezr |
Posted - 04/13/2016 : 10:53:43 AM quote: Originally posted by cpyang
ogs section is a scope, so when exit the scope, all the local variables are gone, so you need to indicate global variables,
See
http://www.originlab.com/doc/Quick-Help/Global-Constants
CP
Thank you. I used the Origin.ini example and it worked. However, if I give the script to someone else, they will have to do the same thing.
So, this solved in part my problem. I would really like how to define the stringArray in the ogs script file so I don't have to configure the Origin.ini |
cpyang |
Posted - 04/10/2016 : 11:48:07 PM ogs section is a scope, so when exit the scope, all the local variables are gone, so you need to indicate global variables,
See
http://www.originlab.com/doc/Quick-Help/Global-Constants
CP
|
|
|