Navigation:  Programmer's Reference > Sending data to DPlot from another application >

FileSaveAs macro command

Print this Topic Previous pageReturn to chapter overviewNext page

Macro commands may be used either in macros or by sending the commands to DPlot via dynamic data exchange (DDE). Some commands are valid only in macros (noted by Macros Only). Commands sent to DPlot via DDE must be enclosed by square brackets [     ]. Macro commands should not include the brackets.

Command parameters shown in the descriptions below are placeholders for the actual values. Command parameters are either numeric values, equations that evaluate to numbers, or character strings. Character string parameters are always bound by double quotation marks. Equations must be preceded by an equals sign (=).

The pipe symbol (|) in the command syntax indicates that a parameter is optional, and should not be included in your macro unless otherwise noted.

All indices into arrays are 1-based, e.g. Curve1=1 refers to the first curve in a plot.

A 0x prefix for numbers in the descriptions below indicates hexadecimal notation; e.g. 0x0010 = 16.

JR/Viewer indicates that the command is supported by DPlot Jr or DPlot Viewer.
JR/Viewer indicates that the command is NOT supported by DPlot Jr or DPlot Viewer.


[FileSaveAs("Plugin Description","filename")

JR   Viewer

Saves the document to filename as:






DPlot file



ASCII data, selected curve only



Comma-separated values



Unformatted data, 32-bit



Tab-separated values



Compressed DPlot file



Unformatted data, 64-bit



Windows metafile



Windows enhanced metafile

For more information on the file types see the description of the Save As menu command. If the "Plugin Description" form is used, the descriptive string must exactly match the description shown in the File Format dialog box, e.g. "BMP Picture".

Metafile notes

DPlot will not save a metafile or an enhanced metafile of a 3D view or a 2D view of a surface plot with the "Type" set to "Shaded bands" (ContourMethod(0)) or "Both lines and shades" (ContourMethod(6)).

Default Filename

If the "filename" argument is left blank or is a filename extension only, the plot title (w/o filename extension) will be used instead. For example, if this macro command:

FileSaveAs("Portable Network Graphics",".png")


is used and the plot title (the text appearing in the title bar) is "ex01.grf", then a PNG file named ex01.png will be saved.

Replaceable Parameters
Starting with version, the filename may include replaceable parameters that are replaced at runtime by one of the title lines from the plot. |TITLE1| is replaced by the first title line, |TITLE2| by the 2nd, and |TITLE3| by the 3rd. These parameters must be in uppercase. For example, this sequence:


Saves the first example plot to the filename "Bicycling Caloric Expenditures.grf" to the c:\mydata folder.

Characters from the replacement string that would be illegal for usage in a filename (\/:*?"<>|) are replaced with an underscore character (_).

Within a macro only, if saving a file that was opened with a FileOpen command (as opposed to ForFilesIn), the filename may include replaceable parameters |PATH|, |FILENAME|, and |EXT|. These will be replaced at runtime by the corresponding elements from the last file opened via FileOpen. For example, this sequence:





reads the file sinewave.csv, performs an FFT on the data and places the results in a new document, activates that new document, then saves the results to the file sinewaveFFT.csv.

The filename argument may include the shortcuts |DPLOTDRIVE|, |DPLOTPATH|, or |DPLOTDOCS| to set the destination drive or full path, respectively, to where DPlot is installed or, for |DPLOTDOCS|, to My Documents\DPlot. This is most often useful when DPlot is installed to a removable drive. All forms must be uppercase and surrounded by the pipe symbol (|) or will be ignored. Please note that the |DPLOTPATH| destination folder may not be acceptable to non-admin accounts on Windows XP and all accounts on Windows Vista and newer versions, depending on where DPlot is installed.

The trailing colon will be included with |DPLOTDRIVE|; similarly the trailing backslash will be included with |DPLOTPATH|. The drive letter and colon are included in |DPLOTPATH|; there is no need to use, for example, "|DPLOTDRIVE||DPLOTPATH|filename.grf".

Macros Only

If placed in a ForFilesIn... NextFile loop, then only a filename extension, preceded by a dot, is used. Exception: if the file specification contains a | (pipe) symbol (see Replaceable Parameters above), then the entire filename is passed to DPlot as is and the filename extension (if any) should be included.
The filename used to save the document will be identical to the original filename but with the extension specified. If omitted, an extension dependent on the type code is automatically selected:






















Filename extensions must be specified if the "Plugin Description" form is used.





 FileSaveAs("BMP Picture",".bmp")



Saves all of the files matching the specification "ex*.grf" as Windows metafiles with the filename extension ".wmf", as DPlot files with the extension ".new", and (if the BMP File Export plugin is present) as RLE-encoded bitmaps with the extension ".bmp".



 FileSaveAs("BMP Picture","c:\temp\|TITLE1|.bmp")



Saves all of the files matching the specification "ex*.grf" as RLE-encoded bitmaps in the c:\temp folder with filename equal to the plot title and a ".bmp" extension.

The dimensions and resolution of bitmap image files ("BMP Picture", "JPEG Picture", etc.) may be specified with the SetPluginImageDims command



Please note:

Character string arguments require a bit of care, depending on your development environment. Character string arguments in all DPlot commands are always enclosed by double quotation marks. In some environments (Visual Basic and all flavors of C, for example), double quotation marks are also used to delineate all character strings (including the command itself). The following example will always cause a syntax error in Visual Basic:

ret = DPlot_Command(docnum,"[FileOpen("myfile.grf")]")

Instead, use:

ret = DPlot_Command(docnum,"[FileOpen(""myfile.grf"")]")

in C, C++, C# you'd accomplish the same thing with:

ret = DPlot_Command(docnum,"[FileOpen(\"myfile.grf\")]");

If a character string argument is a variable, as in (VB):

Dim arg as string
arg = "myfile.grf"

... then you can build the command in VB as:

ret = DPlot_Command(docnum,"[FileOpen(" & chr$(34) & arg & chr$(34) & ")]")

In all flavors of C, the same can be accomplished with

char arg[256];
char cmd[512];
ret = DPlot_Command(docnum,cmd);

This does not apply to the DPlot macro editor, in which each line is by definition a character string and does not require delineators, nor to FORTRAN and possibly other languages, in which the delineator for character strings is a single quote, e.g. '[FileOpen("...")]'

To embed a double quotation mark within a character string which is itself delineated by double quotation marks, use the Symbol font equivalent instead. For example, "Radius=6{\s²}" inches will be processed as





Page url: