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
 Problem reading text after upgrading
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

kippvs

USA
Posts

Posted - 06/04/2011 :  12:57:50 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Using OriginLabPro 8.5.1 SR1 for Windows 7.

Hi there. I've been using the same script in 8.1SR3 with no problems for quite a long time, but just upgraded and am now having problems with it. Here is the basic scripting problem.

I've got two columns of text. I search column 1 row-by-row for a certain value and then read column 2 at the same row, like this:

loop(n,1,wks.nRows)
{
if(wcol(1)[n]$ == "test")
{
readtest$ = wcol(2)[n]$;
}
}
readtest$=;

Really simple, but for some reason this doesn't store anything into 'readtest' - it just comes out empty. On the other hand, if I get rid of the loop and manually point to the correct row, it reads the column 2 value and stores it just fine.

Any idea why this would stop working after upgrading?

Thanks.
~Kipp

easwar

USA
1965 Posts

Posted - 06/07/2011 :  3:49:22 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Kipp,

We will look into why this broke, sorry for the inconvenience. In the mean time, it is better to explicitly declare a variable and use, such as:


int irow;
loop(irow, 1, wks.nrows)
{

}

// or use for loop
for(int irow=1; irow<=wks.nrows; irow++)
{

}



Easwar
OriginLab
Go to Top of Page

greg

USA
1379 Posts

Posted - 06/07/2011 :  5:06:14 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
There are other variables to watch out for when using row index syntax since they are used to access MetaData in the header rows:

%A = col(B)[L]$;%A=; // Long Name
%A = col(B)[U]$;%A=; // Units
%A = col(B)[C]$;%A=; // Comments
%A = col(B)[R]$;%A=; // Sampling Interval
%A = col(B)[P1]$;%A=; // Parameter1
%A = col(B)[Temperature]$;%A=; // User-defined parameter row

If you really mean the values of a variable by the same name, then use:

%A = col(B)[$(L)]$;%A=;
%A = col(B)[$(U)]$;%A=;
%A = col(B)[$(C)]$;%A=;
%A = col(B)[$(R)]$;%A=;
%A = col(B)[$(P1)]$;%A=;
%A = col(B)[$(Temperature)]$;%A=;

N (as a string) was supposed to mean Short Name, but as Easwar points out, there is some problem.
Go to Top of Page

kippvs

USA
Posts

Posted - 06/07/2011 :  5:32:56 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks for the heads-up on column headers. I had no idea that N was reserved for short name. Even declaring as "int n=1" doesn't override this.

I'll just change the variable declarations throughout my scripts as this workaround seems to work fine (although, I am a bit addicted to 'n' in my scripting and will certainly miss using it).

Thanks again, guys.
~Kipp
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