Simple question on definition of variables/strings
abhi2005singh
#pragma rtGlobals=1 // Use modern global access method.
Function test()
String /G list = WaveList("*",";","")
PopupMenu WaveSelect title="Select wave", pos = {10,40}, value = list, proc=WaveSelectProc, mode = 1
End
I get the error:
got "list" instead of a string variable or string function name.
I cannot understand why above code does not compile instead of the fact that I have defined the string variable in the function. The same function will compile without any problem in I define a string named "list" in the root folder using
String list
in the command line.The problem seems trivial but I am not able to figure out what mistake I have committed.
Thanks in advance.
PopupMenu WaveSelect title="Select wave", pos = {10,40}, value = #list, proc=WaveSelectProc, mode = 1
Try that, I think it will work for you.
For more information, scan through the examples for various situations involving the value keyword in the command help for PopupMenu.
May 27, 2011 at 06:01 am - Permalink
But my guess is that this isn't what you want anyway. Your menu will show whatever waves existed at the time that WaveList() is assigned to the global variable. It is likely that you really want a menu of whatever waves exists at the time you use the menu. For that use WaveList directly:
... value=WaveList("*", ";", "") ...
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
May 27, 2011 at 08:55 am - Permalink
I did the same as you suggested (and was working fine) in my previous code, but due to the nature of problem, I have to create new waves but did not want to include those waves in the new menu. So I thought I will create the list beforehand (this I did in a separate function init() but did not show here for the brevity of things) and then refer that that with a string variable "list".
@jtigor and @johnweeks
The #list trick did not work, same error again :(
May 27, 2011 at 10:07 am - Permalink
If your global list is not in the root data folder, you will have to alter the path. In fact, it is recommended that you put globals of that nature somewhere other than root.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
May 27, 2011 at 02:01 pm - Permalink
Thanks. It worked.
May 28, 2011 at 06:34 am - Permalink
In that case you don't need a global string (String/G). A local string will suffice:
String list = WaveList("*",";","")
PopupMenu WaveSelect title="Select wave", pos = {10,40}, value = #list, proc=WaveSelectProc, mode = 1
End
The # sign before list is still needed.
There are a lot of ways to set a popup menu's items and it can be confusing. The reference help for PopupMenu explains them in the section "Setting The Popup Menu Items". This particular method is explained under "# followed by a local string variable specifying items".
May 30, 2011 at 08:44 am - Permalink
Another possibility, if you have flexibility in naming your waves, would be to make use of the string match capability of WaveList.
May 30, 2011 at 02:16 pm - Permalink