Is there a general means to convert an object name to a string? I know about the $ operator to do the reverse. I see the NameOfWave function which returns a string, but how would I get the name of a panel or a control as a string?
Checkout ControlInfo, ControlNameList, WinName, and GetWindow. Some or all of these may be useful to you, depending on exactly what you are trying to do.
NameOfWave exists because there are two ways to reference a wave: via its name or via a wave reference. It provides the conversion from wave reference to name as string.
There is only one way to refer to a control panel or a control - via its name. There is no such thing as a control reference so there is no need for a conversion function.
In the case of global numeric variable, global string variables and data folders, they do have both names and references (NVAR, SVAR, DFREF). There is no conversion function for NVAR or SVAR and I have never felt the need for it. For DFREF you can use the GetDataFolder function.
In Igor there is no object of type "generic reference to object" so there can be no generic NameOfObject function. For example, there is no function that can take either a wave reference or a data folder reference as a parameter. The function must be defined to take one or the other.
If this does not solve the issue for you then we need to know the specifics of what you are attempting to do.
Thanks for the insight about the Igor language features and architecture. Little by little I'm discovering how Igor works.
My reason for raising the issue was that I wanted to write a general procedure that could test and toggle the HIDE state of an arbitrary panel whose name would not be known until runtime. Such a procedure might also test and change other properties such as position, size, color etc. and modify these as needed. Since so far as I know, functions can only take variables, strings, and waves (and in specific cases, structures) as parameters, I wondered how to call such a procedure and pass it the name of a panel or control. Therefore I thought I might need to change a name into a string that could be used a parameter.
I wanted to write a general procedure that could test and toggle the HIDE state of an arbitrary panel whose name would not be known until runtime.
For this you need to use the GetWindow and SetWindow operations. These operations take a window name as a parameter.
You would pass the name of the window as a string parameter to your generic function and convert the string-containing-a-name to a name using the $ operator.
For example:
Function GetWindowHideState(windowNameStr) String windowNameStr // Assumed to contain a valid window name
GetWindow$windowNameStr, hide Variable result = V_Value // Set by GetWindow return result End
For details, execute:
DisplayHelpTopic"Converting a String into a Reference Using $"
April 30, 2015 at 01:05 pm - Permalink
NameOfWave exists because there are two ways to reference a wave: via its name or via a wave reference. It provides the conversion from wave reference to name as string.
There is only one way to refer to a control panel or a control - via its name. There is no such thing as a control reference so there is no need for a conversion function.
In the case of global numeric variable, global string variables and data folders, they do have both names and references (NVAR, SVAR, DFREF). There is no conversion function for NVAR or SVAR and I have never felt the need for it. For DFREF you can use the GetDataFolder function.
In Igor there is no object of type "generic reference to object" so there can be no generic NameOfObject function. For example, there is no function that can take either a wave reference or a data folder reference as a parameter. The function must be defined to take one or the other.
If this does not solve the issue for you then we need to know the specifics of what you are attempting to do.
April 30, 2015 at 01:09 pm - Permalink
My reason for raising the issue was that I wanted to write a general procedure that could test and toggle the HIDE state of an arbitrary panel whose name would not be known until runtime. Such a procedure might also test and change other properties such as position, size, color etc. and modify these as needed. Since so far as I know, functions can only take variables, strings, and waves (and in specific cases, structures) as parameters, I wondered how to call such a procedure and pass it the name of a panel or control. Therefore I thought I might need to change a name into a string that could be used a parameter.
April 30, 2015 at 08:21 pm - Permalink
For this you need to use the GetWindow and SetWindow operations. These operations take a window name as a parameter.
You would pass the name of the window as a string parameter to your generic function and convert the string-containing-a-name to a name using the $ operator.
For example:
String windowNameStr // Assumed to contain a valid window name
GetWindow $windowNameStr, hide
Variable result = V_Value // Set by GetWindow
return result
End
For details, execute:
April 30, 2015 at 09:04 pm - Permalink
ModifyControl
.May 2, 2015 at 01:54 am - Permalink