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
 Worksheet entries using range notation
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

JokerOne

Germany
58 Posts

Posted - 02/11/2016 :  03:06:16 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. 9.1 and Service Release 1
Operating System: Win 7

Beeing a beginner in scripting using LabTalk I really face some issues, that confuses me:

In my concept of a script, I would like to prepare a worksheet template with some column headers (longname, shortname) to be filled with result data.
That means, that I would like to be able to adress the corresponding cells of a worksheet by the shortnames of the worksheet.

I succeded to do so, if I want to enter a string value.
Like entering "Test" in a worksheet cell will work with:

[WorksheetName]SheetNumber!col(shortname)[row]$ = "Test"

However, the more usual case, entering a numeric value fails:
[WorksheetName]SheetNumber!col(shortname)[row] = 3.14
[does not work]
I can use:
[WorksheetName]SheetNumber!Cell(row,col) = 3.14
but here "col" is the col index while I want to use the col's short name.
Also, potentially something like
range aa = ....
aa = 3.14
will work, but appears a bit cumbersome to use in the code.

Is there a one-line code for my task?

Thanks for your help.

Hideo Fujii

USA
1582 Posts

Posted - 02/11/2016 :  09:26:46 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi JokerOne,

> I can use:
> [WorksheetName]SheetNumber!Cell(row,col) = 3.14
> but here "col" is the col index while I want to use the col's short name.

There might be a better way, but at least the following should work:
[Book1]1!Cell(1,ColNum(B)) = 3.14;
Hope this helps.

--Hideo Fujii
Originlab

P.S. Reversely, to get the short/long name from a column number, you can run like:
ii=2;
wks.col$(ii).name$=;
wks.col$(ii).lname$=;
P.P.S.
> range aa = ....
> aa = 3.14
> will work, but appears a bit cumbersome to use in the code.
My favorite style is to use the range notation like following to make the code more consistent throughout, and the range variable name is handy as an alias to be referred at many places:
ii=2;
range aa=[Book1]1!wcol(ii);
aa[1]=3.14;

Edited by - Hideo Fujii on 02/11/2016 09:57:45 AM
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