Help with User-Defined Trace Names
In Igor Pro 10.01, I am trying to provide user-defined names for traces but running into issues. Specifically, I would like to name the trace as the name of the data folder that it is in. However, when I execute the following code in the data folder with path root:dir1, It makes a graph with the trace literally named "dataFolderName" instead of "dir1".
string dataFolderName
dataFolderName = GetDataFolder(0)
display absorbance/TN=dataFolderName vs energy_eVIf I instead execute the following, I get an "expected keyword or name" error at the first parenthesis
display absorbance/TN=(GetDataFolder(0)) vs energy_eVor a "syntax error" at the first parenthesis for the following.
display absorbance/TN=GetDataFolder(0) vs energy_eVEven if I try to manually enter the name as "dir1", I get an "expected keyword or name" error at the quotation mark:
display absorbance/TN="dir1" vs energy_eVI am only successful in renaming the trace dir1 with one of the following:
display absorbance/TN=dir1 vs energy_eVdisplay absorbance/TN='dir1' vs energy_eVHowever, the goal is to automate the naming of traces as the name of their data folder by executing a few lines of code on the command line in the relevant data folder.
As a note, this issue occurs with or without the vs Xwave.
Why does the /TN flag not take a string as an input? Is there another way I can achieve my goal of renaming the trace as the data folder of the wave?
September 13, 2026 at 12:08 pm - Permalink
The /TN flag accepts a 'name', which is distinct from a 'string'. A name would be the unquoted literal text provided to the flag, this is why /TN=dir1 is accepted but /TN="dir1" is not. You can do what you want by using the $ operator to convert the string to a name, like this:
That syntax with $dataFolderName is telling Igor's compiler to use the value of the string as a name. There are a fair number of operations in Igor that expect names instead of strings, so you have to keep this in mind sometimes. A common example of using the $ operator is when you have a string and you want to use it to define the name of a wave that you're going to make:
September 13, 2026 at 12:09 pm - Permalink
That worked, thank you!
September 15, 2026 at 08:36 am - Permalink