Issues creating dependent waves

I'm having a bugger of a time figuring out why my dependencies are broken.

On a button press, I want to load the files, and then make a plot wave which is dependent on the data I've just read in. That way, I can use the plot wave to do other things with in other places.


I made a test function to try out my logic, but it works, and I can't see how it is functionally different to what is below.

function doit() 
	NVAR index =root:index //the global variable I'm using in the dependency already exists

	make/O w ={{1,2,3,4,5},{10,20,30,40,50}} //I'm reading my data into a 2D wave
	
	make/O/N=(dimsize(w,0)) dw //I'm creating my dependent wave from the size of my source wave

	SetFormula dw , "w[p][index]" //I'm setting the dependency in the same manner

end // a successful implementation



Now for my real code:

function loadFilesButtonProc(ctrlName) : ButtonControl
	String ctrlName
	
	//parameters to help me load files, track sizes, and make the dependency. Already exist
	SVAR ext    =root:Packages:AI:LoadPanelFolder:extension
	SVAR pat    =root:Packages:AI:LoadPanelFolder:pattern

	NVAR endSeqno    =root:Packages:AI:LoadPanelFolder:endSeqno
	NVAR endCh       =root:Packages:AI:LoadPanelFolder:endCh

	NVAR seqnoChooser =root:Packages:AI:LoadPanelFolder:seqnoChooser


	//removes a plot so I can kill its wave
	RemoveImage /W=LoadPanel#LoadPanelGraphs#surfPlot /Z surf_y
	
	//creates surf_x, sur_y, and surf_e. 2814 rows, 29 columns (for the debug data)
	// surf_x,y,e may already exist before this line, but get killed in the function before being remade
	// uses "loadwave" to read the text data into igor
	loadwaves("","",extension=ext, pattern=pat)
	
	//gets the size for future updates
	endSeqno = dimsize(surf_y,1)-1
	endCh = dimsize(surf_y,0)-1
	
	//This is my issue: These dependencies are broken, but I can't figure out why.
	//   I've tried making simpler instances, but they work!
	//   I've tried putting some "DoUpdates" in there, but they don't seem to do anything
	make/O/N=(dimsize(surf_y,0)), plot_x, plot_y, plot_e
	SetFormula plot_x , "surf_x[p][seqnoChooser]"
	SetFormula plot_y , "surf_y[p][seqnoChooser]"
	SetFormula plot_e , "surf_e[p][seqnoChooser]"

	//now plot it
	SetActiveSubwindow LoadPanel#LoadPanelGraphs#surfPlot
	AppendImage surf_y
	Label left "Seqno"
	Label bottom "Channel number"
	ModifyGraph mirror=2
	SetActiveSubwindow LoadPanel
	
end



It's probably "seqnoChooser" in
SetFormula plot_x , "surf_x[p][seqnoChooser]"

which is a local alias. Try to replace it with the absolute variable name

SetFormula plot_x , "surf_x[p][root:Packages:AI:LoadPanelFolder:seqnoChooser]"

HJ
Ok, that worked.

I also used a local variable in my short example, but that one was in root, so maybe that was the difference.

Thanks
AND it had an identical name.

NVAR idx =root:index //the global variable I'm using in the dependency already exists
make/O w ={{1,2,3,4,5},{10,20,30,40,50}} //I'm reading my data into a 2D wave
make/O/N=(dimsize(w,0)) dw //I'm creating my dependent wave from the size of my source wave
SetFormula dw , "w[p][idx]"

should not have worked (although the variable is in root).

SetFormula
is working on a global scope. It is not aware that it has been called from a function.

HJ