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
 Accessing Long Names using a variable for col#

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
kemeyer Posted - 06/18/2010 : 10:18:43 AM
Origin Ver. 8.0 SR0
Operating System: Windows Vista

I am writing a small section in my program that will take a string as an arguement and then loop through a worksheet's columns to see if any of the Labels match that string. If the string does match a label, the index of the matching column is returned.

I am having trouble with comparing the two strings. If

myLabel$ is the string to be compared and k is the integer counter for my for loop, I try to use:

if( myLabel$.compareNoCase(col($(k))[L]$)==0 ){

//do Stuff
}

I know the problem lies in accessing the longname. I tried putting some commands in the scrip window and it was able to resolve it when I used an integer instead of k. Is there any way you can make this command work with a variable so that I can loop through all the columns in a worksheet?

Thanks,
Katie
2   L A T E S T    R E P L I E S    (Newest First)
kemeyer Posted - 06/21/2010 : 10:26:15 AM
Thanks!
Laurie Posted - 06/18/2010 : 3:11:36 PM
Hi Katie,

You have to assign the column's long names to a string variable first. You can do something like the following:

string myLabel$ = "SomeLabel"; string strLongName$;
//loop through all columns in active worksheet
loop(ii,1,wks.ncols){
strLongName$ = wcol(ii)[L]$; //wcol() function always expects a column number
//so I use that instead of the col() function
if(myLabel.compareNoCase(strLongName$) == 0)
type -a "Column number $(ii) has a long name of %(strLongName$)";
}

OriginLab Technical Support

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