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
 [] brackets interrupt loop
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

J.S.Schulte

Germany
11 Posts

Posted - 08/15/2016 :  12:15:54 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Pro Ver. 2015G SR2:
Operating System: Windows 7 64 bit

Hi,

I use the following script-lines within a loop to output/copy calculated p-values from a Mann-whitney-test to respective result-sheets:
....
[%(resultate1$)]1!cell(zaehler,2)$=grname$;
[%(resultate1$)]1!cell(zaehler,3)=myMW.Stats.Stats.C3;
....
"resultate1$" is the string variable with the longname of the respective results sheet, "zaehler" is counted upwards during the loop and "grname$" holds the parameter-name for each p-value.

When executed directly in the script-window, everything works as wanted. Within a script-file the loop stops without an error message when reaching those lines. Is it possible that the lines are misinterpreted as sections because of []?
How do I have to change the syntax to get things running?

yuki_wu

896 Posts

Posted - 08/15/2016 :  9:56:50 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

I don't think the lines will be misinterpreted as sections because of []. As a test, you can try to create a new and blank project, and then run the scripts below in Script Window

for(ii=1;ii<5;ii++)
{
	[book1]sheet1!Cell(ii,1)=1;
};


FYI, looping over object is documented here:
http://www.originlab.com/doc/LabTalk/guide/Looping-Over-objs

Yuki
OriginLab

Edited by - yuki_wu on 08/16/2016 04:47:53 AM
Go to Top of Page

J.S.Schulte

Germany
11 Posts

Posted - 08/16/2016 :  08:55:08 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello Yuki,

that is exactly the point: in the Script Window, your test script works fine.

If you put the lines in a script file (.ogs) which you can execute via buttons it does not work!

So, I guess we need another command!

Any suggestions?

Best, Jan
Go to Top of Page

yuki_wu

896 Posts

Posted - 08/16/2016 :  10:57:40 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Jan,

I understand what you mean now, and you guess it right!!!

It is a bug caused by [BookName] being considered as a section.

We have added this problem to our bug tracking database, ID ORG-15148, and will improve it in the future.

Sorry for the inconvenience. Perhaps you can try these scripts below:

range col1=[book1]sheet1!1;
for(ii=1;ii<5;ii++)
{
	col1[ii]=1;
}


Thanks,
Yuki
OriginLab

Edited by - yuki_wu on 08/16/2016 10:58:35 PM
Go to Top of Page

cqy2016

Germany
10 Posts

Posted - 08/17/2016 :  04:13:24 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by yuki_wu

Hi Jan,

I understand what you mean now, and you guess it right!!!

It is a bug caused by [BookName] being considered as a section.

We have added this problem to our bug tracking database, ID ORG-15148, and will improve it in the future.

Sorry for the inconvenience. Perhaps you can try these scripts below:

range col1=[book1]sheet1!1;
for(ii=1;ii<5;ii++)
{
	col1[ii]=1;
}


Thanks,
Yuki
OriginLab




Hi Yuki,

Do you know how to increment the sheet number and layer number?
for example, i have such code as following:
range rr = [Book1]1!$(ii);
page.active=$(ii); //active the worksheet;
plotxy iy:=%(rr)(3,28) plot:=200 ogl:=$(ii);

Here the sheet number is identical as layer number, and i want to plot 2 columns of data from each sheet and put them into one layer of a graph, and then go on with this process till all sheets have been plotted. Do you have a solution for my case?
Go to Top of Page

yuki_wu

896 Posts

Posted - 08/17/2016 :  10:32:42 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi cqy,

An example you can refer to:

//Get the current active workbook name
string bn$ = %H; 
//loop over all worksheets in the current workbook
loop(ii,1,page.nlayers) 
{
  //Add dataset into a specified graph layer	
  plotxy [bn$]$(ii)!(1,2) plot:=200 ogl:=[Graph1]1!;
}

Hope it helps!

Yuki
OriginLab
Go to Top of Page

cqy2016

Germany
10 Posts

Posted - 08/18/2016 :  06:42:42 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by yuki_wu

Hi cqy,

An example you can refer to:

//Get the current active workbook name
string bn$ = %H; 
//loop over all worksheets in the current workbook
loop(ii,1,page.nlayers) 
{
  //Add dataset into a specified graph layer	
  plotxy [bn$]$(ii)!(1,2) plot:=200 ogl:=[Graph1]1!;
}

Hope it helps!

Yuki
OriginLab



Hi Yuki,

Yes, it helped.
Thanks and best regards!

CQY
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