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
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Worksheet entries using range notation

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
JokerOne Posted - 02/11/2016 : 03:06:16 AM
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.

1   L A T E S T    R E P L I E S    (Newest First)
Hideo Fujii Posted - 02/11/2016 : 09:26:46 AM
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;

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000