How do I determine the target graph from inside a function without argument

I'd like to have a function that does something to the current graph, without an argument specifying which graph.

For example, "ShowInfo", without "/W" specified, operates on the target graph (last opened graph) since a named graph was not specified.

How does a function, like ShowInfo, know which graph to operate on, the "target graph"? Is there a global variable that stores the graph name of the last focused graph?

Thanks!

Sincerely,

Zack
Maybe kwTopWin as an alias to the top window is what you have in mind? showinfo/w=kwTopWin. I am not sure if this will work.

best,
_sk
Keep in mind that most functions use an empty string ( "" ) or an omitted /W flag as an identifier for the topmost window.
However, this might get funny results if the user is impatient and focuses another window while that function is running. Here you would really need the name of the initially active window and pass this name to the function.

HJ
I usually use WinName(0,1) to get the currently active graph's name. In a function, you can do something like this (not tested or even compiled:) :
Function DoSomethingToGraph(string gname)
    if (strlen(gname) == 0)
        gname = WinName(0,1)
    endif
   
    ModifyGraph/W=$gname ...
end


John Weeks
WaveMetrics, Inc.
support@wavemetrics.com