Dynamic Text and GetDataFolder()
Hi,
I have a simple interface that let's me switch between directories of data and replete using Replacewave allincdf and then do some refitting. That works all well and good. Now adding some annotations to include specific information including some of the curve fit data.
The working folder is root:hollywood: and within it is a wave called Low_Fit
if I do the following
\{low_fit[0]} to try to get the first value it does not work
I have to give the full path
\{root:hollywood:low_fit[0]} First is this the intended method to require the full path declaration?
Second to get around that since I can't hardcode the path directory, I am trying to use getdatafolder(1) to return the current path. I get a different result from the command window as compared to the annotation box. Is this expected behavior and if so how do I get the correct path format for within the annotation box?
Andy
Hi,
Conversing with WM, apparently the dynamic text construction uses the root directory even if you have a different working directory. A bit of a pain. My workaround was to create a function that builds up the text and then changes the textbox with the /C flag.
Does the job though I think the textbox should respect the working data folder.
Andy
December 3, 2020 at 02:35 pm - Permalink
> Does the job though I think the textbox should respect the working data folder.
I'm curious to understand how this idea should pan out to be reliable and consistent when a graph may have traces with source waves from God-knows-where in a tree structure from the root: folder. In this regard, I appreciate why dynamic text has to be forced to a specific folder location starting from root:.
I do agree that dynamic text could be made "more dynamic" when it could use the return from a string-function call (e.g. as in popup-menu calls). I guess the workaround for this is to use a window hook function to call the Textbox/C flag if the working data folder changes.
December 3, 2020 at 03:59 pm - Permalink
The scenario I am following is that of ReplaceWave allinCDF. The logic is that a graph is created with waves housed in a single datafolder and when the datafolder is changed and the replacewave command given the entire graph is updated accordingly. I find this very useful and helpful for data organization where separate samples/runs with similar wave names can easily coexist. I just move from data folder to data folder. Also the behavior of the textbox with respect to current working directories is unusual. In writing functions that call waves via declarations assume the current data folder unless explicitly stated otherwise. In my example, I need to update not only by data folder but also sample set via the set variable control. My solution was to create a function to explicitly set the text box which is called when the set variable control is fired. The set data folder function also fires the set variable function with a predetermined value (0) when changed. I need to do this since all data folders do not necessarily have same number of samples.
Andy
December 3, 2020 at 04:52 pm - Permalink
You have no idea when the dynamic text is going to be evaluated. It might be when you first create the annotation, but it might be later on when the graph needs to re-draw because you added a trace, or a wave's contents changed. Or you might export the graph and it needs to be redrawn then. The current data folder could change at any point, and so the only way for you to get consistent behavior is for the dynamic text to be evaluated from the root data folder.
December 3, 2020 at 05:23 pm - Permalink
From my limited experience I'd say that the help is right when it says about dynamic text escape codes "In most cases, it is better to generate static text programmatically".
Having said that, you can try something like
return GetWavesDataFolder(TraceNameToWaveRef(graph, traceName), 1)
End
Function MakeGraph()
make data
print fakedata(data)
display
appendtograph data/TN=abcd
TextBox "\\{\"Folder: %s\", GetFolderFromTraceName(\"graph0\", \"abcd\")}"
End
which will update the textbox contents with the data folder of the wave behind the trace. This assumes the graph name and the trace name stays constant. One drawback with the approach of using a user defined function here is that the textbox shows it's source code whenever the procedures are uncompiled.
December 4, 2020 at 06:15 am - Permalink
Hi,
While all the programming things can be done be done, I think that that they require at least a moderate skill level if not very skilled for the use of a window hook. I just see a pretty simple work flow that a new user would do.
The data is similarly named waves grouped together within data folder where the data folder name is the sample name. I think this is a very common arrangement at least for me where probably have used this schema 100+ times.
Now working from a data folder the user creates a graph to their liking and then navigates (even manually) to another data folder to examine that data and takes advantage of the replacewave allinCDF command and if a legend exists it is also updated. Great the new data shows up as expected. Now they want to add a simple annotation that captures the name of the sample which is the data folder name in a simple text box. They can then copy and paste the graph to PowerPoint (Lingua Franca of the business world - unfortunately). Here in lies the request, a simple way to capture the current working folder in an annotation. This use case does not rely on complexities of waves from multiple data folder, but just needs to show the current working folder as an annotation and even the usual methods of doing it are cumbersome for the beginning user. Perhaps as wish list item is a way to get the current working folder as dynamic text, IP knows it since it is visible in other windows.
Andy
December 4, 2020 at 08:25 am - Permalink
In reply to Hi, While all the… by hegedus
The current data folder when dynamic text is evaluated is *always* root.
Other ideas for getting what you are asking for are:
1. Use a tag annotation that is attached to one of the waves on the graph. Then set the text of the tag to something like:
\{GetWavesDataFolder(TagWaveRef(), 1)}
The problem with this approach is that the location of the annotation will be relative to the point in the wave that you attach it to, not relative to the plot area or graph window.
2. Instead of an annotation, add a user-defined shape to the drawing layer (see DrawUserShape). Igor calls your function do draw a user-defined shape, and one of the parameters in the structure is the name of the window containing the shape. From there you can get a reference to a wave on the graph and find the wave's data folder.
December 4, 2020 at 08:56 am - Permalink
> Perhaps as wish list item is a way to get the current working folder as dynamic text, IP knows it since it is visible in other windows.
For this to work it would need to be defined when the dynamic text is evaluated. You can always change the CDF from a background task, dependency etc.
December 4, 2020 at 09:14 am - Permalink