Author |
Topic  |
|
EigenGoofy
64 Posts |
Posted - 05/27/2011 : 11:21:11 AM
|
Origin Ver.: 8.5
Hello!
The reason to call this as a big question is that I don't expect to fully solve this question in one shot. And I will split this question into many sub-small questions, and expect gods here to kill them one by one. The big question posted here is to be used as a reference or guide.
The big question is: In my file clip, there are some ASCII files like these:
r1ekrrun8.XVG (note the difference "ekr" and "ekt") r1ektrun8.XVG r4ekrrun8.XVG r4ektrun8.XVG r12ekrrun8.XVG r12ektrun8.XVG r27ekrrun8.XVG r27ektrun8.XVG r30ekrrun8.XVG r30ektrun8.XVG r63ekrrun8.XVG r63ektrun8.XVG r81ekrrun8.XVG r81ektrun8.XVG
The file clip is located in “D:\program files\origin\”.
Every time I import two files onto my new workbook by using “Import Wizard” and a user defined filter (“Run8filter.oif”).
For example, import “r4ekrrun8.XVG” and “r4ektrun8.XVG”.
Please note that importing “r4ektrun8.XVG” and “r12ekrrun8.XVG” never happen, because it is only allowed to import the two files with the SAME NUMBER on their filename.
Please also note that only importing two files each time is allowed, that is, importing more or less than two is prohibited.
Once after I finished importing “r4ekrrun8.XVG” and “r4ektrun8.XVG”, then open another new workbook to import “r12ekrrun8.XVG” and “r12ektrun8.XVG”.
Question:
I need to write a loop to do the same thing described above. Here is just my rough sketch (maybe helpful):
Filepath$=system.path.program$ + “D:\program files\origin\”; Filtername$=system.path.program$ + “D:\program files\origin\filter\user files\Run8filter.oif”;
for(int ii=1; ii<=total number of files divided by 2; ii++) { newbook;
Open Import Wizard;
Add the first two files (note that the two files must have the same number shown on their file names);
Apply the filter on the two files;
Click the Finish to import; };
So how could I write this code please? Thank you very much!!
|
|
EigenGoofy
64 Posts |
Posted - 05/27/2011 : 11:31:58 AM
|
OK. Let me ask a sub-small question associated with this big question.
Someone suggests to use Xfunction "findfiles".
However, this X-function"findfiles" does not work, because assume that it is able to find the files “r4ekrrun8.XVG” and “r4ektrun8.XVG”, then by ii = ii+1, it is UNABLE to find the files "r12ekrrun8.XVG" and "r12ektrun8.XVG" unless modifying the code manually for each time when ii increases by 1, otherwise, it will still find the same two files regardless of the value of ii.
Moreover, This X-function"findfiles" is UNABLE to match the numbers embedded in the filenames, for example,“r4ekrrun8.XVG” and “r4ektrun8.XVG” are two different filenames, but the numbers embedded in the filenames are the same.
|
 |
|
Shdxqd741
USA
1 Posts |
Posted - 05/29/2011 : 7:33:24 PM
|
I'm confused what your asking? |
 |
|
Shirley_GZ
China
Posts |
Posted - 05/30/2011 : 03:27:21 AM
|
Hi, If you have gotten the file names using ¡§findfiles¡¨ function, all the file names should be arranged in alphabetical order in the output string ¡¥fname$¡¦. As you said, if there are two files that have the same number shown on their file names, the file names of these two files should be adjacent in the output string ¡¥fname$¡¦ . So you just need to import the adjacent two files each time. See this example,
string fns$, path$=system.path.program$ + "Samples\Curve Fitting\" ; findfiles f:=fns$ ext:= "step*.dat"; int n= fns.GetNumTokens(CRLF)/2; loop(ii,1,n) { newbook; jj=2*ii-1; file1$ = fns.GetToken(jj,CRLF)$; impASC fname:=file1$; newsheet; kk=2*ii; file2$ = fns.GetToken(kk,CRLF)$; impASC fname:=file2$; }
http://www.originlab.com/www/helponline/Origin/en/Programming/mergedProjects/LabTalk/LabTalk/Data_Import.html
If this is not OK for you, please contact us with email, tech@originlab.com.
Additionally, next time, if you want to ask further question, it¡¦s better to reply the previous email. It will be easy for me or my colleague to understand your question and provide further support.
Thanks, Shirley
Originlab Technical Service Team |
Edited by - Shirley_GZ on 05/30/2011 03:28:26 AM |
 |
|
rlewis
Canada
253 Posts |
Posted - 05/30/2011 : 04:16:24 AM
|
Whay you are trying to do is relatively straight forward if you are prepared to use OriginC ...
The combination of the following OC functions should do more or less what you want ..
bool GenerateSubFolderName(Folder &ParentFolder, string &strSubFolderName)
{
if(ParentFolder.IsValid()==true)
{
string PathToNewFolder=ParentFolder.GetPath();
strSubFolderName.TrimLeft();
strSubFolderName.TrimRight();
if(strSubFolderName.GetLength()==0)
{
strSubFolderName="subFld";
}
PathToNewFolder+=strSubFolderName;
Folder NewFolder(PathToNewFolder);
int j=0;
bool PreexistingFolderName=NewFolder.IsValid();
while(PreexistingFolderName==true)
{
string strAppend, strNewName, strNewPath;
j++;
strAppend.Format("%d",j);
strNewName=strSubFolderName+"_"+strAppend;
strNewPath=PathToNewFolder+"_"+strAppend;
Folder NextFolder(strNewPath);
if(NextFolder.IsValid()==false)
{
strSubFolderName=strNewName;
PathToNewFolder=strNewPath;
PreexistingFolderName=false;
}
}
return (true);
}
strSubFolderName="";
return (false);
}
void ImportDataFilePairs(string strFileExt, string strFileID1, string strFileID2)
{
strFileID1.TrimLeft();
strFileID1.TrimRight();
strFileID1.MakeLower();
strFileID2.TrimLeft();
strFileID2.TrimRight();
strFileID2.MakeLower();
strFileExt.TrimLeft();
strFileExt.TrimRight();
if(strFileID1.GetLength() ==0 || strFileID2.GetLength() ==0)
{
SetDataDisplayText("One or more Invalid File Identifier Strings Found");
LT_execute("ty -b");
return;
}
vector<string> strFilePaths;
vector<string>strFiletypes;
strFiletypes.SetSize(1);
if(strFileExt.GetLength()==0)
{
strFiletypes[0]="";
}
else
{
strFiletypes[0]="["+strFileExt+" Data Files]*."+strFileExt;
}
string strDlgName="Importing "+strFileExt+" DataFile Pairs .... ";
int NumFiles = GetMultiOpenBox(strFilePaths,strFiletypes,NULL,NULL,strDlgName,false);
if(NumFiles<2)
{
SetDataDisplayText("No Datafile Pairs Found");
LT_execute("ty -b");
return;
}
vector<string>strFilters;
strFilters.SetSize(1);
strFilters[0]="[Origin Import Filters]*.oif";
strDlgName="Importing ImportFilterFile ... ";
string strPathToFilter=GetOpenBox(strFilters,NULL,NULL,strDlgName);
if(strPathToFilter.IsFile()==false)
{
SetDataDisplayText("Import Filter Not Found");
LT_execute("ty -b");
return;
}
Folder FldParent=Project.ActiveFolder();
if(FldParent.IsValid()==false)
{
SetDataDisplayText("Folder Adressing Error");
LT_execute("ty -b");
return;
}
while (strFilePaths.GetSize()>=2)
{
string strPathToFile=strFilePaths[0];
string strFileName=GetFileName(strPathToFile);
string strNameLC=GetFileName(strPathToFile);
strNameLC.MakeLower();
int iFilNameStart=strPathToFile.Find(strFileName);
int IDstart;
IDstart=strNameLC.Find(strFileID1);
string strFound, strToFind;
if(IDstart!=-1)
{
strFound=strFileID1;
strToFind=strFileID2;
}
else
{
IDstart=strNameLC.Find(strFileID2);
if(IDstart!=-1)
{
strFound=strFileID2;
strToFind=strFileID1;
}
else
{
strFilePaths.RemoveAt(0);
continue;
}
}
string strFileStem=strFileName.Mid(0,IDstart);
string strFileStub=strFileName.Mid(IDstart+strFound.GetLength());
string strOtherFile=strFileStem+strToFind+strFileStub;
string strPathToOtherFile=strPathToFile.Left(iFilNameStart)+strOtherFile;
int i;
for(int j=1;j<strFilePaths.GetSize();j++)
{
if(strPathToOtherFile.CompareNoCase(strFilePaths[j])==0)
{
i=j;
break;
}
else
{
i=-1;
}
}
if(strPathToFile.IsFile()==false || strPathToOtherFile.IsFile()==false)
{
SetDataDisplayText("Data File Pair not Found ...");
strFilePaths.RemoveAt(i);
strFilePaths.RemoveAt(0);
continue;
}
string strFldName=strFileStem+"_"+strFound+"_"+strToFind+strFileStub;
strFldName.Replace('.','_');
if(GenerateSubFolderName(FldParent, strFldName)==false)
{
SetDataDisplayText("Folder Adressing Error");
goto ErrorExit;
}
string PathToNewFolder=FldParent.GetPath();
PathToNewFolder+=strFldName;
FldParent.AddSubfolder(strFldName);
Folder NewFolder(PathToNewFolder);
if(NewFolder.IsValid()==false)
{
SetDataDisplayText("Folder Adressing Error");
goto ErrorExit;
}
NewFolder.Activate();
WorksheetPage wP;
wP.Create("Origin",CREATE_HIDDEN);
if(wP.IsValid()==false)
{
SetDataDisplayText("Workbook Adressing Error");
goto ErrorExit;
}
string strWorkBookName=wP.GetName();
wP.AddLayer();
string strTemp;
int iRet=import_file(strWorkBookName,0,strPathToFile,strPathToFilter);
if(iRet==-1)
{
strTemp="File : "+strFileName+" Import or Import Filter Failed";
out_str(strTemp);
FldParent.Activate();
FldParent.RemoveSubFolder(strFldName);
strFilePaths.RemoveAt(i);
strFilePaths.RemoveAt(0);
continue;
}
iRet=import_file(strWorkBookName,1,strPathToOtherFile,strPathToFilter);
if(iRet==-1)
{
strTemp="File : "+strFileName+" Import or Import Filter Failed";
out_str(strTemp);
strFilePaths.RemoveAt(i);
strFilePaths.RemoveAt(0);
FldParent.Activate();
FldParent.RemoveSubFolder(strFldName);
continue;
}
strFilePaths.RemoveAt(i);
strFilePaths.RemoveAt(0);
FldParent.Activate();
}
return;
ErrorExit:
if(FldParent.IsValid()==true)
{
FldParent.Activate();
}
LT_execute("ty -b");
}
|
 |
|
EigenGoofy
64 Posts |
Posted - 05/30/2011 : 5:23:41 PM
|
quote: Originally posted by Shirley_GZ
Hi, string fns$, path$=system.path.program$ + "Samples\Curve Fitting\" ; findfiles f:=fns$ ext:= "step*.dat"; int n= fns.GetNumTokens(CRLF)/2; loop(ii,1,n) { newbook; jj=2*ii-1; file1$ = fns.GetToken(jj,CRLF)$; impASC fname:=file1$; newsheet; kk=2*ii; file2$ = fns.GetToken(kk,CRLF)$; impASC fname:=file2$; }
http://www.originlab.com/www/helponline/Origin/en/Programming/mergedProjects/LabTalk/LabTalk/Data_Import.html
Although I have not tried it yet, I guess that your code will work.
There is something notable on your code - that is - no filter name explicitly specified. However, I am eager to apply my user defined filter upon those ASCII files. For this reason, therefore, I prefer to use what Mr.Greg wrote through email, part of which is shown as following:
findfiles path:=D:\TMP\ ext:=*.dat; filecount = fname.GetNumTokens(CRLF); newbook; for(idx = 1 ; idx <= filecount ; idx++) { string NextFile$ = fname.GetToken(idx,CRLF)$; impFile fname:=NextFile$ filtername:=test.oif location:=2; idx++; NextFile$ = fname.GetToken(idx,CRLF)$; impFile fname:=NextFile$ filtername:=test.oif location:=2; if(idx < filecount) newbook; }
Nevertheless, Shirley, I am really glad that you wrote the code, from which I have just learned how to use syntax "loop". Thank you very much! It is usually and potentially helpful and benefited to see codes in different forms and styles to solve the same problem.
quote:
Additionally, next time, if you want to ask further question, it¡¦s better to reply the previous email. It will be easy for me or my colleague to understand your question and provide further support.
Thanks, Shirley
Oh, Shirley, I had already replied your email on May 27th at 11:10pm. I don't know whether you have gotten that email or not. If you did not get it, then I am sorry.
Thanks very much, Shirley! |
 |
|
rlewis
Canada
253 Posts |
Posted - 05/30/2011 : 7:14:20 PM
|
The OriginC function posted is written as a general purpose routine in which the user defines the datafile type, the means of defining the datafile pairs, and then choses the files to be operated on and the import filter. Once installed as a LT command one would be able to call the function thus
In your particular case, simply open the Script window enter the following commands ... %P="xvg"; %Q="ekr"; %R="ekt"; ImportDataFilePairs(%P,%Q,%R);
You will first be presented a dialog box for selecting the datafiles to be operated upon (it does not matter how many), and then another dialog box for selecting the import filter. Once these selections are made, the program will import each pair of datafiles into separate sheets of a workbook, and each workbook will be placed in a separate folder that is appropriately labeled.
|
 |
|
EigenGoofy
64 Posts |
Posted - 05/31/2011 : 01:29:06 AM
|
quote: Originally posted by rlewis
The OriginC function posted is written as a general purpose routine in which the user defines the datafile type, the means of defining the datafile pairs, and then choses the files to be operated on and the import filter.
I guess that this code generates an impressive user friendly interface. However, I am not prepared to use Origin C. Much of what you wrote is opaque to me, esp no remarks attached to the code lines.
quote:
vector<string> strFilePaths; vector<string>strFiletypes;//Do I please need a space between vector<string> and strFiletypes? (Like "vector<string> strFiletypes") strFiletypes.SetSize(1); if(strFileExt.GetLength()==0) { strFiletypes[0]=""; }
I notice that there are "while" and "for" loop in your code, about which I don't know that if those loops really can import files based on their filenames. As matter of fact, I am slightly lucky in that the file and its corresponding matching file are always located ajacent to one another, since their names are almost the same. That is why the codes from Greg and Shirley work properly in my case. However, if the order of the files are arranged as following, r1ekrrun8.XVG r4ekrrun8.XVG r4ektrun8.XVG r12ekrrun8.XVG r12ektrun8.XVG r1ektrun8.XVG
(Note that in this case r1ektrun8.XVG is not adjacent to r1ekrrun8.XVG.) then the code from Greg and Shirley must have trouble to import the pair of r1ekrrun8.XVG and r1ektrun8.XVG. Hence, building a filename identifier by using logic arguments is the crucial step to rigorously solve this "big" problem.
quote:
Once installed as a LT command one would be able to call the function thus
In your particular case, simply open the Script window enter the following commands ...
%P="xvg"; %Q="ekr"; %R="ekt"; ImportDataFilePairs(%P,%Q,%R);
I save this code as "ImportDataFilePairs.ogs" in my User Files folder, then paste %P="xvg"; %Q="ekr"; %R="ekt"; ImportDataFilePairs(%P,%Q,%R);
to my script window, it just displays "Command Error!"
quote:
You will first be presented a dialog box for selecting the datafiles to be operated upon (it does not matter how many), and then another dialog box for selecting the import filter. Once these selections are made, the program will import each pair of datafiles into separate sheets of a workbook, and each workbook will be placed in a separate folder that is appropriately labeled.
Sounds nice!
Thanks alot for your profusely long code, rlewis. Probably this is a good start-point to me to learn C, though learning Labtalk script is still at the beginning. |
 |
|
rlewis
Canada
253 Posts |
Posted - 06/03/2011 : 01:00:24 AM
|
I've modified the code posted to make its installation a bit easier. (see Below) There are several approaches to the installation of this function ... however the simplest is probably as follows ...
1. Open the CodeBuilder window, create a new C file, paste in the code listed below and save the file to disk. 2. Add the newly created C-File to the System workspace so that function will be available whenever Origin Starts. 3. Select Tools -> Build ... to Compile the code (The code posted should compile without errror) 4. Close the CodeBuilder Window ...
The functions should now be available and can be called from the script Window as posted previously .....
I hope this helps ...
#include <Origin.h>
////////////////////////////////////////////////////////////////////////////////////
typedef int (*PTR_IMPORT_FILE) (LPCSTR strPageName, int nIndexLayer, LPCSTR lpcszDataFile, LPCSTR lpcszFilterName = NULL);
bool GenerateSubFolderName(Folder &ParentFolder, string &strSubFolderName)
{
if(ParentFolder.IsValid()==true)
{
string PathToNewFolder=ParentFolder.GetPath();
strSubFolderName.TrimLeft();
strSubFolderName.TrimRight();
if(strSubFolderName.GetLength()==0)
{
strSubFolderName="subFld";
}
PathToNewFolder+=strSubFolderName;
Folder NewFolder(PathToNewFolder);
int j=0;
bool PreexistingFolderName=NewFolder.IsValid();
while(PreexistingFolderName==true)
{
string strAppend, strNewName, strNewPath;
j++;
strAppend.Format("%d",j);
strNewName=strSubFolderName+"_"+strAppend;
strNewPath=PathToNewFolder+"_"+strAppend;
Folder NextFolder(strNewPath);
if(NextFolder.IsValid()==false)
{
strSubFolderName=strNewName;
PathToNewFolder=strNewPath;
PreexistingFolderName=false;
}
}
return (true);
}
strSubFolderName="";
return (false);
}
void ImportDataFilePairs(string strFileExt, string strFileID1, string strFileID2)
{
strFileID1.TrimLeft();
strFileID1.TrimRight();
strFileID1.MakeLower();
strFileID2.TrimLeft();
strFileID2.TrimRight();
strFileID2.MakeLower();
strFileExt.TrimLeft();
strFileExt.TrimRight();
strFileExt.MakeLower();
if(strFileID1.GetLength()==0 || strFileID2.GetLength()==0)
{
SetDataDisplayText("One or more Invalid File Identifier Strings Found");
LT_execute("ty -b");
return;
}
vector<string> strFilePaths;
vector<string>strFiletypes;
strFiletypes.SetSize(1);
if(strFileExt.GetLength()==0)
{
strFiletypes[0]="";
}
else
{
strFiletypes[0]="["+strFileExt+" Data Files]*."+strFileExt;
}
string strDlgName="Importing "+strFileExt+" DataFile Pairs .... ";
int NumFiles = GetMultiOpenBox(strFilePaths,strFiletypes,NULL,NULL,strDlgName,false);
if(NumFiles<2)
{
SetDataDisplayText("No Datafile Pairs Found");
LT_execute("ty -b");
return;
}
vector<string>strFilters;
strFilters.SetSize(1);
strFilters[0]="[Origin Import Filters]*.oif";
strDlgName="Importing ImportFilterFile ... ";
string strPathToFilter=GetOpenBox(strFilters,NULL,NULL,strDlgName);
if(strPathToFilter.IsFile()==false)
{
SetDataDisplayText("Import Filter Not Found");
LT_execute("ty -b");
return;
}
Folder FldParent=Project.ActiveFolder();
if(FldParent.IsValid()==false)
{
SetDataDisplayText("Folder Adressing Error");
LT_execute("ty -b");
return;
}
while (strFilePaths.GetSize()>=2)
{
string strPathToFile=strFilePaths[0];
string strFileName=GetFileName(strPathToFile);
string strNameLC=GetFileName(strPathToFile);
strNameLC.MakeLower();
int iFilNameStart=strPathToFile.Find(strFileName);
int IDstart;
IDstart=strNameLC.Find(strFileID1);
string strFound, strToFind;
if(IDstart!=-1)
{
strFound=strFileID1;
strToFind=strFileID2;
}
else
{
IDstart=strNameLC.Find(strFileID2);
if(IDstart!=-1)
{
strFound=strFileID2;
strToFind=strFileID1;
}
else
{
strFilePaths.RemoveAt(0);
continue;
}
}
string strFileStem=strFileName.Mid(0,IDstart);
string strFileStub=strFileName.Mid(IDstart+strFound.GetLength());
string strOtherFile=strFileStem+strToFind+strFileStub;
string strPathToOtherFile=strPathToFile.Left(iFilNameStart)+strOtherFile;
int i;
for(int j=1;j<strFilePaths.GetSize();j++)
{
if(strPathToOtherFile.CompareNoCase(strFilePaths[j])==0)
{
i=j;
break;
}
else
{
i=-1;
}
}
if(strPathToFile.IsFile()==false || strPathToOtherFile.IsFile()==false)
{
SetDataDisplayText("Data File Pair not Found ...");
strFilePaths.RemoveAt(i);
strFilePaths.RemoveAt(0);
continue;
}
string strFldName=strFileStem+"_"+strFound+"_"+strToFind+strFileStub;
strFldName.Replace('.','_');
if(GenerateSubFolderName(FldParent, strFldName)==false)
{
SetDataDisplayText("Folder Adressing Error");
goto ErrorExit;
}
string PathToNewFolder=FldParent.GetPath();
PathToNewFolder+=strFldName;
FldParent.AddSubfolder(strFldName);
Folder NewFolder(PathToNewFolder);
if(NewFolder.IsValid()==false)
{
SetDataDisplayText("Folder Adressing Error");
goto ErrorExit;
}
NewFolder.Activate();
WorksheetPage wP;
wP.Create("Origin",CREATE_HIDDEN);
if(wP.IsValid()==false)
{
SetDataDisplayText("Workbook Adressing Error");
goto ErrorExit;
}
string strWorkBookName=wP.GetName();
wP.AddLayer();
string strPath;
strPath.Format("%sOriginC\\OriginLab\\fileimport.c", GetAppPath(TRUE));
Function fn = Project.FindFunction("import_file", strPath,true);
PTR_IMPORT_FILE pfn = fn;
if(!pfn)
{
SetDataDisplayText("Cannot Locate Originlab Function");
goto ErrorExit;
}
int iRet=pfn(strWorkBookName,0,strPathToFile,strPathToFilter);
string strTemp;
if(iRet==-1)
{
strTemp="File : "+strFileName+" Import or Import Filter Failed";
out_str(strTemp);
FldParent.Activate();
FldParent.RemoveSubFolder(strFldName);
strFilePaths.RemoveAt(i);
strFilePaths.RemoveAt(0);
continue;
}
iRet=pfn(strWorkBookName,1,strPathToOtherFile,strPathToFilter);
if(iRet==-1)
{
strTemp="File : "+strFileName+" Import or Import Filter Failed";
out_str(strTemp);
strFilePaths.RemoveAt(i);
strFilePaths.RemoveAt(0);
FldParent.Activate();
FldParent.RemoveSubFolder(strFldName);
continue;
}
strFilePaths.RemoveAt(i);
strFilePaths.RemoveAt(0);
FldParent.Activate();
}
return;
ErrorExit:
if(FldParent.IsValid()==true)
{
FldParent.Activate();
}
LT_execute("ty -b");
}
|
 |
|
EigenGoofy
64 Posts |
Posted - 06/05/2011 : 8:54:40 PM
|
Hi, rlewis.
I did all the steps, and it returns green words "Cannot Locate Originlab Function".I don't know what function is missing. My files I am working with are in another place on my disk seperated from the main program of Originlab. And there is no such file and path on my disk. (OriginC\\OriginLab\\fileimport.c)
Despite of this, However, I can see that this must be a nice program. |
 |
|
rlewis
Canada
253 Posts |
Posted - 06/06/2011 : 12:09:17 AM
|
That error message indicates an execution error triggered by a failure to find the function "import_file". In Versions starting from Origin 8.1, the function "import_file" is coded in the file "FileImports.c".
The lines of code directing the program to that file and the function are ...
strPath.Format("%sOriginC\\OriginLab\\fileimport.c", GetAppPath(TRUE));
Function fn = Project.FindFunction("import_file", strPath,true);
Please make sure that the lines of code in the file you've compiled are exactly as indicated above ...
If there is no error there, then take a look in the main Origin Folder ... there should be a Folder called "OriginC" within which there should be a subFolder called "OriginLab". The File "FileImports.c" should be in that subFolder. If that file is not there, then there may have been an error when Origin was either installed or updated ...
|
 |
|
EigenGoofy
64 Posts |
Posted - 06/08/2011 : 12:58:11 AM
|
Hi rlewis.
The file path was: D:\Program Files\origin\The whole program\OriginC\OriginLab\FileImport.c
I tried your code:
strPath.Format("%sOriginC\\OriginLab\\fileimport.c", GetAppPath(TRUE)); Function fn = Project.FindFunction("import_file", strPath,true);
which appeared "Cannot Locate Originlab Function".
Then I modified it by:
strPath.Format("D:\Program Files\origin\The whole program\OriginC\OriginLab\FileImport.c ", GetAppPath(TRUE)); Function fn = Project.FindFunction("import_file", strPath,true);
Then clicked "Rebuild", it appeared: Linking... D:\Program Files\origin\The whole program\OriginC\OriginLab\FILEIMPORT.C(1059) :Error, Function ConvFilter@CAAAAAAAOGAAAAAAOGAAAAAA was called, but its body could not be located during linking. Linking Failed!
I have checked whether there is any mistake on the filepath due to my type, but nothing I have found, and I didn't know why its linking failed.
P.S. there are some cases that a program is unable to recognize "The whole program" unless by changing it to "The_whole_program". I don't know if CodeBuilder has the same problem or not. |
 |
|
EigenGoofy
64 Posts |
Posted - 06/08/2011 : 5:23:34 PM
|
I have just tried your program on another machine, and it seemed to work! Nice!
However, the program did not satisfy my requirement, since each time it imported only one ASCII file if selecting two ASCII files, among which the latter one might be imported, and the former one was not. If selecting multiple ASCII files more than just two, then it did import each pair, yet on two different workbooks, rather than on a single sheet of one workbook.
Anyway, it is a good program! Thank you very much for sharing it, rlewis! |
 |
|
rlewis
Canada
253 Posts |
Posted - 06/08/2011 : 11:00:34 PM
|
Hi ... Some of the behavior you describe seem rather odd to me .. I've rechecked the code and it should do what you want ...
But, to improve the efficiency of the routine remove the following lines from within the "while loop" and place them just before the line "while(strFilePaths.GetSize()>=2)"
string strPath;
strPath.Format("%sOriginC\\OriginLab\\fileimport.c", GetAppPath(TRUE));
Function fn = Project.FindFunction("import_file",strPath,true);
PTR_IMPORT_FILE pfn = fn;
if(!pfn)
{
SetDataDisplayText("** ERROR ** Cannot Locate Originlab Function **");
LT_execute("ty -b");
return;
}
Incidentally ... What version of Origin are you using .. Use Help->About Origin to determine the actual version and build ... |
 |
|
|
Topic  |
|
|
|