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
 Accessing Long Names using a variable for col#
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

kemeyer

39 Posts

Posted - 06/18/2010 :  10:18:43 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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

Laurie

USA
404 Posts

Posted - 06/18/2010 :  3:11:36 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

kemeyer

39 Posts

Posted - 06/21/2010 :  10:26:15 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks!
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