View previous topic :: View next topic |
Author |
Message |
Tedow
Joined: 16 Sep 2005 Posts: 3
|
Posted: Thu Dec 29, 2005 4:52 pm Post subject: FileSaveAs in a macro not capturing all files? |
|
|
I'm attempting to save every .grf file in a directory as a JPG file. The macro I'm using looks like this:
ForFilesIn("C:\blahblahblah\*.grf")
FileSaveAs("JPEG Picture", ".jpg")
FileClose()
NextFile
In this particular case I have 50 files I'm trying to operate on. The problem: even though the macro cycles through all 50 files (I counted them flashing up on the screen), I only get like 34 JPG files out. Any idea on what could be causing the problem? A memory space issue maybe? Directory name length (actual directory name is much longer than "blahblahblah")? Too many files?
I only did a cursory search to see if this problem has arisen before, so apologies if it's a repost. |
|
Back to top |
|
|
DPlotAdmin Site Admin
Joined: 24 Jun 2003 Posts: 2310 Location: Vicksburg, Mississippi
|
Posted: Thu Dec 29, 2005 6:15 pm Post subject: |
|
|
I haven't run into this one before but will look into it. The total length of the filename including the path is limited to 256 characters; if that's a problem for you please let me know. Other than that the only thing I can think of off the top of my head is that there's a synchronization problem, as in somehow a file is being closed before it is saved as a JPEG. After writing that down, though, it doesn't sound right. I'll let you know if/when I find anything. _________________ Visualize Your Data
support@dplot.com |
|
Back to top |
|
|
DPlotAdmin Site Admin
Joined: 24 Jun 2003 Posts: 2310 Location: Vicksburg, Mississippi
|
Posted: Thu Dec 29, 2005 7:59 pm Post subject: |
|
|
One other thing occurred to me: if any of those filenames include a + or @ character then that's the likely explanation for what's going wrong. Although those files can be opened using the Open command on the File menu, a FileOpen or ForFilesIn command will fail. That's due to legacy code from the days when + and @ weren't legal characters in filenames. + is used as a separator for multiple files. @ is used to denote a script file containing a list of files to open. I'm working on a workaround for both of those characters. _________________ Visualize Your Data
support@dplot.com |
|
Back to top |
|
|
DPlotAdmin Site Admin
Joined: 24 Jun 2003 Posts: 2310 Location: Vicksburg, Mississippi
|
Posted: Thu Dec 29, 2005 11:54 pm Post subject: |
|
|
I've found an unexpected problem with saving images in a loop. If you use the default dimensions (width and height = 0) what should happen is the image will be the same size as the document window. But it appears that a timing problem is causing goofy, impossible values to be given for the document window dimensions. This in turn causes the file export to fail (though no error message is produced). If this is the source of the problem you're having you can get around it by adding SetPluginImageDims:
SetPluginImageDims(640,480) ' use whatever dimensions you want
ForFilesIn("C:\blahblahblah\*.grf")
FileSaveAs("JPEG Picture", ".jpg")
FileClose()
NextFile
I'll definitely fix this before the next release. Of course if this isn't the problem and you also don't have filenames containing a + or @, please let me know. _________________ Visualize Your Data
support@dplot.com |
|
Back to top |
|
|
Tedow
Joined: 16 Sep 2005 Posts: 3
|
Posted: Tue Jan 03, 2006 10:44 am Post subject: |
|
|
1) Okay, my filename/path length is only 110 characters, so that's not the problem.
2) None of the filenames include + or @. There are parentheses, but those are the only "special" characters.
3) I tried running the macro with a Pause in between the FileSaveAs() and FileClose() commands, but that didn't help.
4) The first time I ran a case with 32 files and the SetPluginDims(1600,1200) (necessary to get the legend and note text size to roughly match what shows on my screen), it worked on all 32 files. However, when I tried on 50 files, the problem occurred as before. When I went back to 32 files, I was unable to repeat the earlier success. Have you been able to duplicate the problem on your system? Maybe it's something unique the POS I'm running on...?
Ted |
|
Back to top |
|
|
DPlotAdmin Site Admin
Joined: 24 Jun 2003 Posts: 2310 Location: Vicksburg, Mississippi
|
Posted: Tue Jan 03, 2006 11:13 am Post subject: |
|
|
Ted,
Thanks for the detailed reply. I don't have a good answer at the moment but will hunt the problem down as soon as possible.
My guess is that if you insert a Pause before the FileSaveAs() rather than after that all will work. I'm not suggesting this as a solution, since you'd be forced to babysit your computer and continually hit a key. _________________ Visualize Your Data
support@dplot.com |
|
Back to top |
|
|
DPlotAdmin Site Admin
Joined: 24 Jun 2003 Posts: 2310 Location: Vicksburg, Mississippi
|
Posted: Thu Jan 05, 2006 1:22 am Post subject: |
|
|
Ted,
Found it. DPlot was failing to delete bitmap images after saving them to JPEGs (or PNGs, TIFs, etc.). You can get the fixed version by selecting Help>Check for Updates. Thanks for pointing out the problem. _________________ Visualize Your Data
support@dplot.com |
|
Back to top |
|
|
Tedow
Joined: 16 Sep 2005 Posts: 3
|
Posted: Fri Jan 06, 2006 4:16 pm Post subject: |
|
|
Jackpot, that did the trick. Thanks Dave. |
|
Back to top |
|
|
|