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?
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$)"; }