macro questions - user interaction

Have a suggestion for improving DPlot or a question about existing features? Let us know

Moderator: DPlotAdmin

Post Reply
CPC
Posts: 8
Joined: Tue Jul 02, 2013 6:11 am

macro questions - user interaction

Post by CPC »

I am trying to write a macro that will process test data and compare it to computer model data and I have come up with a couple of questions.

I have the macro written to the point where it works for a specific case with specific file names, but I would like to make it more globally useful without needing to manually edit the file references each time. Currently the macro reads in the test data file, performs some operations, then reads in the model data. Instead of explicitly saving the file names in the macro, is it possible to prompt the user for the files to be opened with the FileOpen and FileAppend commands? Ideally, I would like the macro to interact with the user and work something like this:

prompt user for a title
store title as VAR_A
FileOpen the test data through user prompt
perform operations on test data
FileAppend computer model data through user prompt
store path of FileAppend as VAR_B=Request("path")
set Directory("VAR_B")
format graph and add titles
FileSaveAs(1,"VAR_A")

Would something like that be possible through the Dplot macro? I tried to make my intention as clear as possible, but please let me know is something make sense.



Also, while trying to perform operations on the curves, I ran into a problem. I am trying to double integrate acceleration data to get displacement and I originally wrote the macro as follows:

SelectCurve(1) 'select acceleration
Integrate() 'integrate acceleration to create curve 2 (velocity)
SelectCurve(2) 'select velocity curve
Integrate() 'integrate velocity curve for displacement

When I tested that macro, I found that the integration was applied to the acceleration data (curve 1) twice, resulting in two identical velocity curves rather then velocity and displacement. I was able to get around that by erasing acceleration to make velocity curve 1 and integrating again:

SelectCurve(1) 'select acceleration
Integrate() 'integrate acceleration for velocity
EditErase() 'erase acceleration
Integrate() 'integrate velocity (now curve 1) for displacement
EditErase() 'erase velocity

Though my workaround is acceptable, I was concerned that the macro seemed to ignore my curve selection and I might not be able to operate on specific curves. Was I misusing SelectCurve, or was there some other mistake that I made in the original macro?

Again, if anything is unclear, let me know and I will try to come up with a better explanation. I appreciate any help that you can provide.
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

The first part isn't possible, sorry. Maybe someday DPlot macros will be more programmable, but don't hold your breath for that.

On the Integrate problem, that's not what I get when I tried just now. Your first macro works exactly as I would expect. This isn't something I've changed recently, so either you're using a very old version or there's some weirdness associated with the version of Windows you're using. If you don't have a recent version of DPlot please update with Help>Check for Updates. And if that doesn't help let me know what version of Windows you're running.
Visualize Your Data
support@dplot.com
Post Reply