Inconsistent Compile Error

Hi guys,

I'm getting an inconsistent error when I try to compile my script.
The error is inconsistent given that it does not always appears.
Essentially, it seems Igor does not recognizes my string list I use for a PopupMenu.

String DataTypeList = "Duration;Area;Magnitude;Velocity;Frequency (Hz);Frequency (bpm);Gap Time"
String SectionList = "Whole Event;Contraction;Relaxation;Ratio (C/R)"
DoUpdate
   
//TOP ROW
   
//GRoup0
PopupMenu SelectData0 title="Data Type", bodyWidth=80, pos={370,2},value=DataTypeList
PopupMenu SelectSection0 title="Section", bodyWidth=80, pos={490,2},value=SectionList


I attach an image to illustrate and you can see the error message, and the DataTypeList string list
If I indicate a literal string, such as  "this is a literal string" instead of a string variable as the value for SelectData0 PopupMenu, then a similar error will occur for the next PopupMenu in line: SelectSection0 - and SectionList string variable will return error at compile time.

I cannot understand why this does not compile, let alone why it is not consistent.

Anyone with any ideas?

IgorCompileError.jpg
Note that, in your screen dump, you do not have:
String DataTypeList

but rather
String/G DataTypeList

Don't create global variables except for things that have to persist from one invocation of a function to the next.

When posting a question, if possible, it is best to create a minimal self-contained function that illustrates the problem. For example:
Function Test()
    String DataTypeList = "A;B;C;"
    PopupMenu SelectData0 value=DataTypeList
End


I can test this and see that it does not compile.

Looking at the help for PopupMenu, I see that the documentation for the value keyword refers me to the "Setting The Popup Menu Items" section. In that section, I see a number of options, but I do not see "the name of a local string variable" as an option. From that section I can see that this compiles:

Function Test()
    String DataTypeList = "A;B;C;"
    PopupMenu SelectData0 value=#DataTypeList   // # followed by a local string variable specifying items
End

Thank you!

This was very helpful. The use of # was not intuitive for me. In addition, I realized the need to express "\" as part of the list string. I was in part confused by the fact that if the string had previously been created by a previous run (with /G flag) then there was no error. Hence I was under the impression that the statement was correctly written - it clearly was not!

The following now works well:

Function PanelTest()
   
    String DataTypeList

    String quote = "\""

    DataTypeList = quote + "A;B;C;" + quote
   
    NewPanel /W=(0,0,1100,565) /K=1 /N=DCR0 as "Results Display Panel"
   
    PopupMenu SelectData0, title="Data Type", bodyWidth=80, pos={370,2}, win=DCR0, mode=1, value=#DataTypeList
End


Cheers,

R.