Transferring variable values between Data folders
I'm a relative newcomer to Igor programming and I'm having trouble with moving variable or Wave values between Data Folders using Functions.
I have legacy code that performs various analyses via Functions, which operate on data in different Folders. I wish to be able to "harvest" the results of operations in each of the functions into a single wave that resides in root: and which can be reported on in a summary Table. I do not want to do much editing of the various Functions to alter Folder structures; I just want to collect the value of various data in various Folders into root:
I've been trying to use "MoveWave" to temporarily move the "collection" wave (called "Value", which is already created in root: before running the Functions below) into the correct data folder where the Function is operating, assign the value of the result of the calculation to an element of "Value" wave, and then transfer the "collection" wave back out into root:
I've been trying something like this, which doesn't seem to get the value of "Result_1" into Value[0]:
Initialize()
setDataFolder root:
WAVE/T Value
// "Value" is a pre-existing wave in root:
Value[0]=""
Value[1]=""
end
Function_1()
setDataFolder root:Folder_A
Variable Result_1
WAVE/T Value
// Analysis to calculate a value for variable Result_1
MoveWave Value, root:Folder_A
Value[0]=Result_1
MoveWave Value, root:
end
Is there a better way for me to go about trying to collect Function results into root: ?
Terry
p.s. trying something very simple like root:Value[0]=Result_1 in the Function does not seem to accomplish the hopping of values between Data Folders either...
Hi,
In your function_1(), you could reference the value wave in the root folder with
wave/T value = root:value
Then do the assignment with
Value[0] = Result_1
You do not need to move the "Value" wave.
Andy
June 6, 2024 at 12:08 pm - Permalink
Not sure it this is part of the problem, but function_1() tries to assign a numeric value (Result1) to a text wave. Also have a look at data folder references, DFREF, which are very useful when operating on waves in different folders. Your function_1 may then look like this:
setDataFolder root:Folder_A
DFREF homeDF = root:
wave/T ValueWave = homeDF:value
Variable Result_1 = pi
ValueWave[0]=num2str(Result_1)
end
June 7, 2024 at 04:19 am - Permalink
I'm not sure he can use DFREF in Igor 5...
June 7, 2024 at 09:43 am - Permalink
hegedus: your suggestion fixed my problem. Thanks!
ChrLie: I was working with all text waves (though I didn't make that clear), so this wasn't the issue.
johnweeks: I'm running Igor Pro 8.
Thanks all.
June 15, 2024 at 07:47 pm - Permalink
Wow. Where did I get the idea you were running Igor 5? I think I confused your posting with another one...
June 17, 2024 at 09:47 am - Permalink