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
 setting a variable to a cell value

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
MegW Posted - 06/25/2012 : 4:53:32 PM
Origin Ver. and Service Release (Select Help-->About Origin):8.5
Operating System:XP
I have a worksheet that has dates in column A and corresponding data collection session identification numbers in column B. I want to use the date (collected from the user as a string variable called date$) to get the value of the corresponding session number in the same row of column B, and set a variable called "sess" equal to that cell value. Basically, sess = row(date$) of col B. (1) Can I do this without using any kind of extract function and (2) if so, what is the appropriate LabTalk syntax? I've tried about 50 variations.
3   L A T E S T    R E P L I E S    (Newest First)
Kathy_Wang Posted - 06/28/2012 : 9:06:21 PM
Hi,

I'm not sure what lead to your problem, as when I tried the codes are working fine.

The error message "col2[nn] is an undefined variable" appears to me that instead of using "col(2)[$(nn)]", you were using the syntax "col2[nn]" somewhere, and this might be the problem.

Also sess=-- might indicate that nn returns to 0 value, i.e. no matching string is found.

I think you could first check this by yourself, if it's still not solved, please send your project file including the worksheet to tech support so we can investigate.

You could follow the instructions below to send your file.
http://www.originlab.com/index.aspx?go=Support&pid=752

Kathy
Originlab
MegW Posted - 06/28/2012 : 11:20:16 AM
Thanks, Kathy. I tried this code as well as several variations but cannot get it to work. I either get an error message that col2[nn] is an undefined variable (with nn being the number of the row in question, like 12), or I'm told that sess = --. Most of the variations I've tried involve specifically designating which worksheet of the open workbook I want to use. I've also tried having that worksheet active as I type the commands into the command line. Always one of those two results. I'll read more about these commands and see if I can figure out what's going on.

-Meg
Kathy_Wang Posted - 06/26/2012 : 01:29:02 AM
Hi,

You may create a string array of your column A and use the "Find" command to return to corresponding row index, and then use the row index to access corresponding cell in column B.

An example would be:

//Append the string variables in column A as a string array
StringArray aa;
range r1=col(1);
aa.Append(r1);
//Pop up a dialog to let user input a date.
getstring  (Type the date here);
//%B stores the user-input date as a string variable
string date$=%B;
//return to the row index of the matching date in string array
int nn = aa.Find(date$);
//return to the corresponding cell of col B, the variable type may need to change according to your data
double sess=col(2)[$(nn)];
sess=;


You might refer to the following two pages for more information and examples of the StringArray:Find and getstring command:

http://www.originlab.com/www/helponline/Origin/en/Programming/mergedProjects/LabTalk/LabTalk/StringArray_(object).html#Find

http://www.originlab.com/www/helponline/Origin/en/programming/mergedProjects/LabTalk/LabTalk/GetString_(command).html

Please note that the hyperlink might not work for direct clicking, then you will need to copy and paste the address into your browser, sorry for the inconvenience.

Kathy
Originlab

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