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
 Origin Forum
 getn-function, cell value
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

RedAndWhite

8 Posts

Posted - 07/12/2012 :  10:15:48 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi,

Is it possible to access cell values with the getn-function directly?

I am currently using the following code, but that way i am getting a lot of variables to use.

win -a book1

aa$ = cell(4,42)$;
bb$ = cell(5,42)$;
.
.

getn
(name-1) aa$
(name-2) bb$
.
.

I tried

(name-1) cell(4,42)$

but it doesent work.

Thanks,
Stefan


Hideo Fujii

USA
1582 Posts

Posted - 07/12/2012 :  6:27:55 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Stefan,

GetN command takes only variable names there as the obtained values from the interaction will be set to these variables.

One possible way you may consider is to define a macro such as:
///////////////////////
def mycells {
  aa$ = cell(%1,42)$;
  bb$ = cell(%2,42)$;
  getn (name-1) aa$ (name-2) bb$;
  cell(%1,42)$=aa$;
  cell(%2,42)$=bb$;
}
////////////////////
Then, when you run the following macro calling command with arguments:

  mycells 4 5;

Hope this helps.

--Hideo Fujii
OriginLab

Edited by - Hideo Fujii on 07/12/2012 10:13:23 PM
Go to Top of Page

RedAndWhite

8 Posts

Posted - 07/13/2012 :  02:53:36 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Hideo,

Thanks for your reply.

I thought about another way. Is it possible to have a changing/running variable, like aa1, aa2, aa3,...
and put such into a loop, like:


for(i=1; i<=20; i++)
{
cell(i,40)$ = aa(i)$;
};


Stefan
Go to Top of Page

Hideo Fujii

USA
1582 Posts

Posted - 07/13/2012 :  11:25:03 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Stefan,

Sure, as LabTalk is an interpreter language, you can compose a variable name, etc.
in a string way. For example,
aa1$="A";
aa2$="B";
aa3$="C";
for(ii=1; ii<=3; ii++) {
  cell(ii,1)$ = aa$(ii)$;
};
should work. Please note that the $(...) notation to convert a number to a string.
Also, I used "ii" instead of "i" because it is a system variable in Origin.

--Hideo Fujii
OriginLab
Go to Top of Page

RedAndWhite

8 Posts

Posted - 07/13/2012 :  3:52:39 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Hideo,

Thanks you very much. I am pretty new in scripting, so there are a lot of problems rising ;)

Is there any good tutorial for learning the notations, for example, like "$", "%" and "!" ???


Stefan
Go to Top of Page

Hideo Fujii

USA
1582 Posts

Posted - 07/13/2012 :  6:25:07 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Stefan,

There is no tutorial, but LabTalk Guide has the explanation of "substitution notations",
$(...) and %(...) in the LabTalk help:

LabTalk Programming> Guide> Language Fundamentals> Special Language Features> Substitution Notation

Or, the same online:
http://wiki.originlab.com/~originla/ltwiki/index.php?title=LabTalk:Substitution_Notation

Hope this helps.

--Hideo Fujii
OriginLab
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