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
 loop for defining range variables
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

JamCheck

2 Posts

Posted - 11/09/2012 :  04:44:57 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release: OriginPro 8.6.0 (64-bit) b70 (Academic)
Operating System: MS Windows Server 2008 R2 Standard

Hello,
I am trying to define a lot of range variables, each of them consisting of a column, to create a data sheet which contains the results of a global fitting procedure. One variable (column) is reserved for one parameter and I want to save the differently indexed results in the corresponding cells. In principle, this works, but I encounter problems when I try to define the range variables in a loop:
loop (ii , 1 , 20) {
range c$(ii)=[book1]sheet1!Col($(ii));
}

Thereafter, the variables are not defined. This is especially strange since if I do the same manually, i.e.
ii=1;
range c$(ii)=[book1]sheet1!Col($(ii));
ii=2;
range c$(ii)=[book1]sheet1!Col($(ii));
...

the definitions work perfectly fine. Why is this and how can I do it with the loop?

Thanks a lot for your help,
Jan

greg

USA
1378 Posts

Posted - 11/09/2012 :  1:16:42 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Variables declared within '{' '}' will go out of scope once you exit.

You can use
@global = 1;
to enforce any following variables to be global in scope.
You can use
@global = 0;
to resume normal scoping rules.
Go to Top of Page

JamCheck

2 Posts

Posted - 01/07/2013 :  07:10:08 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by greg

Variables declared within '{' '}' will go out of scope once you exit.

You can use
@global = 1;
to enforce any following variables to be global in scope.
You can use
@global = 0;
to resume normal scoping rules.



It works perfectly now, thanks for your prompt reply - this was exactly the hint I needed.
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