Trouble using dfref's that are stored in a dfref wave
I made a dfref wave in the root directory ( cd root; make/DF/N=1 refWave = { root:NameOFMyFolder } ; )
I try to use ( SetDataFolder root:refWave[0] ) and get "expected ';' or <cr>" with the left square bracket now highlighted in the command window.
I try inserting a point to the refWave [after the 0th index] in case for some random reason waves with one entry are not to be indexed.
So it seems that SetDataFolder sees root:refWave and says "ok, I need to find the folder root:refWave ... but this command is not ended with carriage return or ; ... so let's send an error"
I also cannot seem to print the 10-digit number which corresponds to the dfref ( print root:refWave[0] )
Any help on this issue is much appreciated.
I'm pretty sure you can not use datafolder reference waves on the command line.
In a function like
NewDataFolder/O/S myfolder
Make/DF/O dfrs = {GetDataFolderDFR()}
SetdataFolder root:
print GetDataFolder(1)
DFREF dfr = dfrs[0]
SetdataFolder dfr
print GetDataFolder(1)
End
I get
which looks right.
August 3, 2022 at 10:23 am - Permalink
You wrote that the DF wave item is "root:NameOFMyFolder" and then tried SetDataFolder root:refWave[0] , which to my mind, expands to "root:root:NameOFMyFolder." This is surely going to raise and error.
August 3, 2022 at 01:47 pm - Permalink
Thank you all. Indeed, I do not see a way to use DF waves in command line or to pass a dfref between functions using DF waves in root: folder in a very direct way, but the workaround works fine.
In addition to the workaround posted above, I use something like:
SetDataFolder( needsRef ) ;
End
Function giveRef( int index )
//This is the one I call from the command line and so can't give it a dfref directly
wave/DF refWave = root:NameOfMyRefWave ;
dfref theRef = refWave[index] ;
useRef( theRef ) ;
End
August 4, 2022 at 12:05 pm - Permalink
> or to pass a dfref between functions using DF waves in root: folder in a very direct way
That is possible with something like
NewDataFolder/O/S myfolder
Make/DF/O dfrs = {GetDataFolderDFR()}
DoSomething(dfrs)
End
Function DoSomething(WAVE/DF wv)
DFREF dfr = wv[0]
print GetDataFolder(1, dfr)
End
August 10, 2022 at 11:03 am - Permalink