Macro for loading multiple data files

Beta releases, announcements and anything else that doesn't fit below. Please read the <B>Welcome</B> topic.
Post Reply
azeigle
Posts: 5
Joined: Fri Oct 09, 2020 12:50 pm

Macro for loading multiple data files

Post by azeigle »

I'm new to DPlot and want to write a macro which loads multiple csv files into a new plot. I have something kind of working, but would like to expand it's capabilities. Below is what I have written so far.

Code: Select all

FileNew()
FileType(4)
ForFilesIn("D:\macro_test\*.csv",A)
VAR_C=Request("fname")
Legend(1,"VAR_C")
NextFile
Improvements I would like to make:
1. Set each curve name to the file name. Right now it sets the name of the current file to curve 1. I can't find any documentation on numeric variables and how I can use them to update the curve number each time through the loop.

2. Is it possible to do any kind of string manipulation on string variables (such as VAR_C) so I can strip off the file extension, or use only part of the file name, etc?

3. When it opens a file, it asks me to specify which columns to plot. I want to set it to alternating x,y columns, and choose all the columns. Can this be automated so I don't have to set these options and click OK for each file?

And one unrelated question. Is it possible to specify a default font type for the macro editor? I prefer monospace fonts for scripting. But right now I have to set the font type every time I open the editor.
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

1. Unfortunately "Use as Legend" only works when you open multiple files OR when you're appending to an existing graph (where there is already a "Curve 1").
2. Sorry, no. And this will not likely happen with macros.
3. ColumnsAre(0) will get rid of that dialog box and use all columns.

If the macro editor is closed normally (i.e. not a crash) then the font should be preserved - it is for me when I tried just now.
Visualize Your Data
support@dplot.com
azeigle
Posts: 5
Joined: Fri Oct 09, 2020 12:50 pm

Post by azeigle »

Thanks for the quick response! The font I choose is now coming up as the default. I'm not sure what I was doing wrong before.
Post Reply