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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 passing argument to script file
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

sjwu77

USA
Posts

Posted - 11/28/2004 :  03:48:25 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi there,

I'm confused by this problem:

I tried to call a script and pass a number (say, 3) to the file, as

run.section(myScript,Main,3);

In my Script, 3 is used to make the name of a worksheet
[Main]
...
%I=data$(%1);
...

Then some data manipulation is performed. Everything seems to be fine.

Now I try to run the scripts with a sequence of numbers as argument:

for (num=1;num<=10;num++) {run.section(myScript,Main,num);}

The labTalk seems always perform the last one, e.g., num=10, and do nothing to num from 1 to 9...

Could anyone help me to figure out any possible problem here?

Thanks a lot

Saijun

Mike Buess

USA
3037 Posts

Posted - 11/28/2004 :  08:20:32 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Saijun,

The problem must lie in your [Main] scripts. To verify, change them to this...

[Main]
type $(%1);
return;
...

I will be very surprised if you don't see this...

for (num=1;num<=10;num++) {run.section(myScript,Main,num);}
1
2
...
9
10

Mike Buess
Origin WebRing Member
Go to Top of Page

sjwu77

USA
Posts

Posted - 11/28/2004 :  3:19:03 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Mike,

Here is my subroutine:

myScript.ogs
//////////////////////////////////////////////////////
[Main]

pts=50;
curve.reset();
curve.smoothleftpts=pts;
curve.smoothrightpts=pts;
curve.smoothpts=2*pts+1;
%I=data$(%1);
type %I; // I add this line as you suggested
curve.x$=%(%I,1);
curve.data$=%(%I,2); ;
curve.result$=%(%I,3);
curve.adjave();
sum(%(%I,3));
return;

/////////////////////////////////////////////////////////
run.section(myScript,Main,1)
gives
data1
and correct data smoothing as I expected

When I run
for (num=1;num<=3;num++) {run.section(myScript,Main,num)
gives:
data1
data2
data3
However, the data smoothing only happen at the worksheet "data3"!

If, I manually input
run.section(myScript,Main,1) and run
run.section(myScript,Main,2) and run
run.section(myScript,Main,3) and run
The data1,2,3 are smoothed accordingly.

If, However, I select the three line altogether and run at once, same thing happens as when I use the for loop...

Any further suggestion? Thanks a lot





Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 11/29/2004 :  08:40:04 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
An extra semicolon is delaying execution...

curve.data$=%(%I,2); ;

Remove the 2nd semicolon and your script will work fine.

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 11/29/2004 08:58:09 AM
Go to Top of Page

sjwu77

USA
Posts

Posted - 11/29/2004 :  1:16:25 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
all right. I never thought of ";"
It works now
thanks a lot Mike
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000