using SavePict in a function
Hi,
I am trying to write a simple function to save a graph as an emf figure using a function. Typically, I use the SavePict/e=-2 as "myfigure.emf" with the command prompt and that works just fine. However when I implement this in a function, please see the code below, I get an erratic behavior. Most often I get the "While executing SavePICT, the following error occurred: no target window" error, every now and then it works just fine, and occasionally the following message is printed in the command window: " ** SavePict gave error: no target window ". If you know what is going on and how to solve this issue, please let me know.
Ultimately, what I am trying to achieve is to have a function that allows me to save the top graph using a dialog box.
Thank you!
S
string graphName = WinName(0,1)
if(strlen(graphName)==0)
doAlert 0, "No figure selected!"
return 0
endif
SavePict/E=-2/win=graphname as "MySpectra.emf"
end
SavePict/E=-2/win=$graphname as "MySpectra.emf"
In your function you are using the literal name `graphname` and not your string variable. There is no graph named `graphname`, hence the error.
January 23, 2022 at 12:29 pm - Permalink
In reply to SavePict/E=-2/win=$graphname… by sjr51
Ha! That, of course works. Thank you!
January 23, 2022 at 12:32 pm - Permalink