Author |
Topic  |
|
SteffenG
Germany
Posts |
Posted - 01/20/2009 : 08:34:31 AM
|
Origin Ver. 8G SR4 Operating System: WinXP
Hi,
I wrote a script to do some things with the data reader tool and the script runs fine if I start the script from the script window (I prefer the old one from Origin 7.5.). Now I tried to place the script in an OGS file, added a section identifier (I used [main].) and bind the OGS file to a custom button. If I hit the button it looks like that the first commands running very well but the self defined macros pointproc and quittoolbox will be ignored.
Is the use of the macros not possible within OGS files? Thanks for help, Steffen
PS: Here is the script: [main]
newsheet b:=%[%C, '_'] n:=PointsConnected u:=1 xy:=XY; range aa=[%[%C, '_']]PointsConnected!; colsalt=aa.ncols; AA.NCOLS=$(colsalt+2); range xx = [%[%C, '_']]PointsConnected!col($(colsalt+1)); range yy = [%[%C, '_']]PointsConnected!col($(colsalt+2)); xx.type = 4; yy.type = 1; ii=0; dotoolbox 3 ; // Datareadertool; def pointproc { ii++; xx[$(ii)]=X; yy[$(ii)]=Y; }; def quittoolbox { win -o (%[%C, '_']) { page.active$=PointsConnected; sort -c $(colsalt+1) $(colsalt+2) xx; }; layer -i202 yy; set yy -cl 1; set yy -cse 18; set yy -csf 18; set yy -z 15; }; return 0;
|
|
SteffenG
Germany
Posts |
Posted - 01/22/2009 : 10:26:45 AM
|
Hi,
after some trial and error I found the problem. If one declare a variable like the range variable aa or xx in the script the pointproc macro or any other macro has no knowledge about this variable because it is a session variable. It looks like the macros run in another environment regardless the definition of the macro was made in the [main]-section. To declare the variables as global variables which are active in the complete Origin environment I followed the help file and add the line @global = 1; right after the declaration of the section [main]. Now the script is running in the same way as in the script window.
Regards, Steffen |
 |
|
cpyang
USA
1406 Posts |
Posted - 01/22/2009 : 9:24:10 PM
|
I am glad you found the answer as this one was really tricky.
Thanks for sharing the info.
CP
|
 |
|
|
Topic  |
|
|
|