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
 Forum for Origin C
 Programming File Import Filters
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

hajo_old

Germany
141 Posts

Posted - 01/20/2003 :  09:06:51 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic


Hello, all

how can I program some file import filters for several file types we use at our company?

I thought of an integrated extension of the filter choosebox in the file-open dialog (e.g. *.xls; *.txt). We use severel text files with different encodings, comments and data formats. So by simply choosing the file type, the files should be read in into a workbook and for example the comments and units should be filled in.

we use the normal Origin 7 version (till now not the PRO Version).

Thanks for any hints or even better solutions!!

Hans-Jrg Koch
SiemensVDO
Germany

eparent

118 Posts

Posted - 01/20/2003 :  10:12:52 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
In version 8 we plan to make it easier for users to add file types to Origin's File Open dialog and File Import menu. You tell Origin what extensions are associated with your files and then write your import routine in Origin C. Origin will handle the call to your import routine from File Open, File Import, and drag-and-drop.


Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 01/20/2003 :  12:56:10 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Meanwhile, you can set up your own filters in Origin 7 with a little effort. There are several approaches but I'll just discuss the method that seems easiest to me. In the following LabTalk script I assume you have two types of files, ASCII (*.dat, *.txt) and Excel (*.xls). I also assume that you have a template ready for each type (AsciiTemplate.otw and ExcelTemplate.otw) with the appropriate ASCII options already set up. Put the scripts in the [Main] section of Custom.ogs and launch them with the Custom Routine button.

run.section(File,Init); // initialize the file dialog
fdlog.dlgName$="Custom import"; // dialog title
fdlog.numTypes=4; // number of extensions
fdlog.type1$="[ASCII (*.dat)] *.dat";
fdlog.type2$="[ASCII (*.txt)] *.txt";
fdlog.type3$="[Excel (*.xls)] *.xls";
fdlog.type4$="[All files (*.*)] *.*";
if(fdlog.open(A)==1) break 1;
%B=fdlog.path$;
%Z=%B%A; %A=Origin;
// fdlog.deftype=extension number of selected file
switch (fdlog.deftype) {
case 1: %A=AsciiTemplate; break;
case 2: %A=AsciiTemplate; break;
case 3: %A=ExcelTemplate; break;
default: break;
};
win -t D %A; // open the appropriate template
open -wc %Z; // import the file

Consult the fdlog object in the LabTalk programming guide for tweaking options.

Hope this helps. Post back if you get stuck.

Mike Buess
Origin WebRing Member
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