GetLastUserMenuInfo
viralvector
When I have multiple waves from the same folder, It can identify the waves.
However, when I have multiple waves showing in the same graph from different folders, the operation failed.
I read the ihf and it states
The GetLastUserMenuInfo operation sets variables in the local scope to indicate the value of the last selected user-defined menu item.
Is there an operation like GetLastUserMenuInfo but can identify the waves from different folders? if not, is there a code for advancing such function?
Thanks.
Documentation of GetLastUserMenuInfo indicates that S_traceName is set in that case. A graph and trace name uniquely identifies the concerned wave.
January 29, 2014 at 01:48 am - Permalink
I am sorry that I don't understand the meaning of graph's trace contextual menu.
Here is the code which I tried to create a menu called "Show_Tag_All_info" to Tag waves in a graph.
I believe the graph's traces works only if there are all in the same folder.
If I create a graph macro with many waves from different folders, the following code failed to recognize the waves from other folders. (The waves would not show up in the menu)
WaveList("*",";","Win:"), DoItem()
End
Function DoItem()
GetLastUserMenuInfo // sets S_value, V_value, etc.
WAVE/Z w= $S_value
wavestats/Q $S_value
variable xPeak = V_maxloc
variable xSdev = V_sdev
variable Vskew=V_skew
variable Vavg =V_avg
variable Vsum =V_sum
variable Vpoint = V_npnts
variable Vmin=V_min
Variable Vmax=V_max
Variable Vminloc =V_minloc
//Variable VendRow= V_endRow
if( WaveExists(w) )
//Tag /F=2/S=3/A=MT/X=6.42857/Y=14.346 $S_value,xPeak, "\\Z09\\ON The Xpeak \\OX"
Print NameOfWave(w),"", xPeak,"and the SD is", xSdev, "skew value", Vskew
String TextIt
sprintf TextIt, "\\Z09 \\K(0,65280,0)\\ON \rresults: \rxPeak=%g, \rAvg=%g, \rSum=%g, \rVminloc=%g, \rVpoint=%g, \rSD=%g, \rVskew=%g", xPeak,Vavg,Vsum, Vminloc ,Vpoint, xSdev,Vskew
Tag /F=2/S=3/A=MT/B=(0,0,0) /X=6.42857/Y=14.346 $S_value,xPeak, TextIt
// TextBox/C/N=FitResults TextIt
endif
End
January 29, 2014 at 09:30 am - Permalink
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
January 29, 2014 at 10:09 am - Permalink
Thanks for the tip! I did some searches in the forum and found similar code, and it worked.
However, I have one minor issue. In my previous function, I can click on a wave to create a tag for the wave.
With the following code, it just tags all the waves in macro graph. How do I make a code for the tagging selective wave?
I believe it is because of
index +=1
But I dont't know how to modify it.
TraceNameList ("",";",1), TagAll()
End
Function TagAll()
String list = TraceNameList("", ";", 1)
String traceName
Variable index = 0
do
traceName = StringFromList(index, list)
if (strlen(traceName) == 0)
break // No more traces.
endif
WAVE w = TraceNameToWaveRef("", traceName)
wavestats/Q w
variable xPeak = V_maxloc
Print NameOfWave(w),"", xPeak
GetLastUserMenuInfo
String TextIt
sprintf TextIt, "\\Z09 \\K(0,65280,0)\\ON\rxPeak=%g", xPeak
Tag /F=2/S=3/A=MT/B=(0,0,0) /X=6.42857/Y=14.346 $s_value,xPeak, TextIt
// Smooth 5, w
index += 1
while(1)
End
January 30, 2014 at 09:19 am - Permalink
TraceNameList ("",";",1), DoItem()
End
Function DoItem()
GetLastUserMenuInfo // sets S_value, V_value, etc.
TagATrace(S_value)
end
Function TagATrace(tracename)
String tracename
WAVE w = TraceNameToWaveRef("", traceName)
wavestats/Q w
variable xPeak = V_maxloc
Print NameOfWave(w),"", xPeak
String TextIt
sprintf TextIt, "\\Z09 \\K(0,65280,0)\\ON\rxPeak=%g", xPeak
Tag /F=2/S=3/A=MT/B=(0,0,0) /X=6.42857/Y=14.346 $s_value,xPeak, TextIt
// Smooth 5, w
end
Function TagAll()
String list = TraceNameList("", ";", 1)
String traceName
Variable index = 0
do
traceName = StringFromList(index, list)
if (strlen(traceName) == 0)
break // No more traces.
endif
TagATrace(traceName)
index += 1
while(1)
end
I've included a new TagAll function just to show how it would work with the re-factored code. But you don't really need it.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
NOTE in edit: I just noticed that I left a useless GetLastUserMenuInfo in the TagATrace function.
January 30, 2014 at 10:15 am - Permalink
Great! Thank you for being so patient with me!
January 30, 2014 at 01:32 pm - Permalink