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
 import data with or without a filter
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

redman

UK
59 Posts

Posted - 11/26/2008 :  06:49:40 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. 8.0 and SR4 (Select Help-->About Origin):
Operating System: XP

Previously, I learned from the forums, and got a working script file (see script file 1 below) for automatic importing and plotting ASC as well as SPC data. But I failed to import mass spectra data using almost the same codes except impfile X function with a user defined filter. Finally, I solved the problem by minor modification of the codes, see script file 2, but there is a funny result puzzling me:

I tried to trace the variable at two locations in the Loop loop. At the first location (colored red) where the loop just starts, every result seems ok, but at the second location just after the impfile x function (colored blue), it becomes unpredictable.

My questions are:
1. What's the real reason why the script file 1 can not simply employed for the second purpose?
2. Why does the loop variable behavior so strange?

Thanks a lot for your attention!

Script file1:
//-----------------------------------------------------------------------------------------------------
Second -i;
int count=0;
dlgfile m:=1 g:=*.TXT t:="Import Multiple TXT"; // multifile dialog result in fname$
int count=fname.GetNumTokens(CRLF);
type -a "count=$(count)";
newbook s:=0; // new book without any sheet
loop(ii,1,count) {
type -a "ii1=$(ii)";
string strFile$ = fname.GetToken(ii,CRLF)$;
newsheet c:=1; //default to just 1 col
impasc fname:=strFile$;
//run.section(,Common01);
type -a "ii2=$(ii)";
if (ii < count) newbook s:=0;
}
//----------------------------------------------------------------------------------------------------

When importing 3 TXT data file, it script window displayed:
count=3
ii1=1
ii2=1
ii1=2
ii2=2
ii1=2
ii2=2


Script file 2:
//---------------------------------------------------------------------------------------------------
int count=0;
dlgfile m:=1 g:=*.csv t:="Import Multiple CSV"; // multifile dialog result in fname$
int count=fname.GetNumTokens(CRLF);
type -a "count=$(count)";
//newbook s:=0; // new book without any sheet
newbook;
ii=0;
loop(ii,1,count) {
type -a "ii1=$(ii)";
string strFile$ = fname.GetToken(ii,CRLF)$;
//newsheet c:=1; //default to just 1 col
impfile fname:=strFile$ filtername:=MassScan.oif location:=user;
// run.section(,PlotData);
type -a "ii2=$(ii)";
//if (ii < count) newbook s:=0;
};
//---------------------------------------------------------------------------------------------------

When import 3 TXT data file, it script window displayed:
count=3
ii1=1
ii2=5
ii1=2
ii2=7
ii1=2
ii2=18


greg

USA
1380 Posts

Posted - 12/04/2008 :  09:43:44 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
In a test using Origin 8SR4 I could not reproduce your results. The only difference between my code and yours is that I had to change to a filter that I had on my system. This leads me to suspect that your filter has some script that runs after import that is using the variable ii.

Origin does have scoping rules that would allow two variables of the same name to exist with different values, but if my suspicion is correct then the first 'ii' is expressing the loop structure 'ii', while the second is expressing the filter code 'ii' and the end of loop test is re-setting the scope of ii. If this is the case, then that would be a bug, but the programmers would have to have code in hand that reproduces the problem.

Please send your filter and a sample datafile to tech@originlab.com for analysis.
Go to Top of Page

redman

UK
59 Posts

Posted - 12/05/2008 :  05:32:16 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi, grey,

You are so great! I just checked my filter, there was indeed a script using the same variable ii. Once I changed one of the variable names, the above mentioned script file1 could work fine with a filter.

Many thanks!

Redman
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