Author |
Topic  |
|
abutler
UK
5 Posts |
Posted - 11/01/2001 : 09:44:51 AM
|
Hi. I am new to Labtalk, and would greatly appreciate some help for the program I want to write. I want to open about 70 seperate text files, one at a time, as matrix format, set the matrix dimensions (or will Origin use the same as are in the currently open matrix?), then do a 3D graph, using a template, and export the graph image as a JPEG. I cannot yet get multiple file opening part to work, even though I followed the examples I thought. Help/suggested script for the whole application would be great! Do the files I am importing need to be in the "software directory"? My file opening code so far is:
type -a; getfile -m *.txt;
for (ii=1;ii<=count;ii ++) { getfile -g ii;
type "%A"; \\for now to see if it does anything! };
The import multiple files dialog box opens, I select multiple files, then nothing happens. I know I haven't written much, but until this works I cannot progress! Thankyou in advance.
|
|
Mike Buess
USA
3037 Posts |
Posted - 11/01/2001 : 10:09:24 AM
|
Comments are preceded by "//", not "\\". Your script should work if you correct or remove the comment.
Mike Buess Origin WebRing Member |
 |
|
abutler
UK
5 Posts |
Posted - 11/01/2001 : 10:17:01 AM
|
Sorry, I just added this comment for the question since it isn't what I want to do. The original code doesn't have it in, and still seems not to work. Ta. |
 |
|
Mike Buess
USA
3037 Posts |
Posted - 11/01/2001 : 11:21:22 AM
|
I copied the script from your message, pasted it in the script window and removed the comment. Then I highlighted the entire script and hit enter. It worked fine in Origin 6.1. You might try removing the space between "ii" and "++" in the for statement, but that didn't effect the execution when I ran it.
There are no restrictions on the location of the files you are importing. "getfile -g ii" assigns the name and full path of the iith file to the string variable %A.
Mike Buess Origin WebRing Member |
 |
|
abutler
UK
5 Posts |
Posted - 11/01/2001 : 11:50:36 AM
|
OK. I agree it works. I was trying to run the script by saving it, then running it with: run "full path to saved script"
This opens the multiple file box, but doesn't print the names out afterwards. Any ideas why not/a better way to run it-I guess just highlight works fine? I will now try to write the rest of the script, and get back to you if there are other problems. Thanks for getting me started: It's only easy when you know how. |
 |
|
CStorey
Canada
137 Posts |
Posted - 11/01/2001 : 11:52:52 AM
|
This works for me too in Origin 6.1 SR3. What happens for me is a script window is opened, an OPEN dialog appears prompting me to select some files, and when I do the names are written to the script window. This is exactly what I expected but maybe not what you were looking for.
Maybe you want to try the commands
win -t plot "TemplateName" Graph~$(ii); %R=%H; //Open a graph template win -n wks Wks$(ii); //Create a wks for the data file open -w %A; %W=%H; //Import data
These will open a graph from a template. Open a wks template. Import your data file into the open wks.
From there you just need to figure out how to plot the data.
Also be aware that the getfile command has been replaced with the FDlog methods. You can do the same things I mentioned above with the FDlog method script below.
/// FDlog Import script FDLog.DlgName$="Select Files to Import."; FDLog.ShowComment=0; FDlog.path$="C:\"; // Default path FDLog.numtypes=3; FDLog.type1$=[TXT files]*.TXT; FDLog.type2$=[DAT files]*.DAT; FDLog.type3$=[All files]*.*; FDLog.defType=1; FDLog.multiOpen.sort=0; If(FDLog.MultiOpen()!=0/0) { Loop(nn,1,FDLog.MultiOpen.Count) { win -t plot "TemplateName" Graph~$(nn); %R=%H; //Open a graph template win -n wks Wks$(nn); //Create a wks for the data file FDLog.Get(A, nn); ;; Get name of data file open -w %A; %W=%H; //Import data }; }; Return;
Hope this helps, Craig
Craig Storey Origin WebRing Member - http://nav.webring.yahoo.com/hub?ring=originwebring
Edited by - CStorey on 11/01/2001 12:00:18
Edited by - CStorey on 11/01/2001 12:01:52 |
 |
|
abutler
UK
5 Posts |
Posted - 11/01/2001 : 4:21:26 PM
|
Hi. Thanks for your earlier help. I've almost got the script I want. I cannot get the script to output the graph as a JPG, I get the error message filter failed to load. Manually exporting works fine. When I manually export, no options as to bit depth, size etc are given-how do I get the script to use the defaults? Incidentally the 3D graph seems to rescale X and Y2 but not Z even though the rescale options in the template are all set the same-hence my layer1.X.inc=200; command. The script now is: /// FDlog Import script FDLog.DlgName$="Select Files to Import."; FDLog.ShowComment=0; FDlog.path$="C:\Data\"; // Default path FDLog.numtypes=3; FDLog.type1$=[TXT files]*.TXT; FDLog.type2$=[DAT files]*.DAT; FDLog.type3$=[All files]*.*; FDLog.defType=1; FDLog.multiOpen.sort=0;
If(FDLog.MultiOpen()!=0/0) { Loop(nn,1,FDLog.MultiOpen.Count) { win -t mat "MatrixTemplate1.OTM" Mat$(nn); //Create a Mat for the data file win -a Mat$(nn); //Set Current Matrix Active FDLog.Get(A, nn); //Get name of data file open -w %A; %W=%H; //Import data win -r %H Mat$(nn); //Rename matrix worksheet -p 242 "3dgraph3.otp" Graph$(nn); %R=%H; //Open a graph template and plot Graph$(nn)!layer1.X.inc=200; Graph$(nn)!layer1.Y2.inc=200; win -a Graph$(nn); //Set Current Graph Active image.filename$=%W.JPG; image.export.pagepixel(JPG, 640, 480, 24, 10); win -c Mat$(nn); win -c Graph$(nn); }; }; Return;
Thanks again.
|
 |
|
CStorey
Canada
137 Posts |
Posted - 11/02/2001 : 10:52:14 AM
|
Image export depends on which version of Origin you are using. In general you would use something like...
%L="DirectoryName"; %V="JPG"; ibits=24; pic_width=xxx; pic_height=yyy; image.filename$="%L%H.%V"; image.ShowOptions=0; // No Image Export Dialogs!! image.export.tempRaster=2; // BMP/EPS raster
//Origin 6.1 Export format!! image.export.PagePixel(%V,pic_width,pic_height,ibits,0);
//Origin 6.0 Export format!! image.exportPixel(%V,pic_width,pic_height,24,0);
Note - Compression is not supported, that may have been the problem.
Hope this helps.
Craig Storey Origin WebRing Member - http://nav.webring.yahoo.com/hub?ring=originwebring |
 |
|
|
Topic  |
|
|
|