View previous topic :: View next topic |
Author |
Message |
azeigle
Joined: 09 Oct 2020 Posts: 5
|
Posted: Fri Oct 09, 2020 1:02 pm Post subject: Macro for loading multiple data files |
|
|
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: | 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. |
|
Back to top |
|
|
DPlotAdmin Site Admin
Joined: 24 Jun 2003 Posts: 2311 Location: Vicksburg, Mississippi
|
Posted: Sat Oct 10, 2020 7:10 am Post subject: |
|
|
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 |
|
Back to top |
|
|
azeigle
Joined: 09 Oct 2020 Posts: 5
|
Posted: Mon Oct 12, 2020 6:52 pm Post subject: |
|
|
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. |
|
Back to top |
|
|
|