Accessing structure member in Note operation
jtigor
The compiler doesn't like
Note/NOCR w, sHeader.sHeader
Where sHeader.sHeader references a string structure member. The compiler reports "expected a keyword or an object name" pointing to the "." in the structure reference. A very quick look through the manual turned up nothing on this syntax. I can work around this by first assigning the member to a string and using the string in the operation. Am I missing something in using a structure reference in the Note operation or is this a limitation of structures?
I feel as though I've encountered this before, but can't recall the details.
Thanks,
Jeff
In order to investigate I had to create a minimal self-contained example:
String sHeader
EndStructure
Function Test()
Make/O wave0 = p
STRUCT MyStruct s
Note/NOCR wave0, s.sHeader
End
Having done that, I can verify the compile error that you report.
The solution is to use ""+s.sHeader. The leading empty string helps Igor's compiler understand that the parameter is a string.
The fact that the compiler needs this help seems like a flaw but there is probably a technical reason for it.
June 17, 2020 at 04:51 pm - Permalink
In reply to In order to investigate I… by hrodstein
Howard,
Your solution works. And, I'm sure I've been through this before. Somewhere in the forum/list archive is a dusty message where I asked the same question.
Thanks,
Jeff
See: https://www.wavemetrics.com/forum/general/structure-element-path-input-newpath-operation
June 17, 2020 at 07:09 pm - Permalink