The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Script runs in Script window but not as OGS

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
SteffenG 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;
2   L A T E S T    R E P L I E S    (Newest First)
cpyang 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
SteffenG 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

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000