xradiobutton action with procedure string output

Using the graphical user interface to build and exercise models. Includes customizing the GUI by writing a little bit of hoc or Python
Post Reply
Konstano

xradiobutton action with procedure string output

Post by Konstano »

Hello,

I have a peace of a code that does not work normally.
Here it is:

Code: Select all

strdef procAstr, procBstr, procCstr, procDstr, modelm_one, modelm_two, modelm_three 

sprint(modelm_one, "modelmode(%d)", 0)
sprint(modelm_two, "modelmode(%d)", 1)
sprint(modelm_three, "modelmode(%d)", 2)

proc procA() {
}

proc procB() {
}

proc procC() {
}

proc procD() {
}

proc modelmode() {local mmode
	mmode=$1
	sprint(procAstr, "procA(%d)", mmode)
	sprint(procBstr, "procB(%d)", mmode)
	sprint(procCstr, "procC(%d)", mmode)
	sprint(procDstr, "procD(%d)", mmode)
}

xpanel("")
	xlabel("")
	xradiobutton("a", modelm_one)
	xradiobutton("b", modelm_two)
	xradiobutton("c", modelm_three)

	xlabel("")
	xradiobutton("A", procAstr)
	xradiobutton("B", procBstr)
	xradiobutton("C", procCstr)
	xradiobutton("D", procDstr)	
xpanel()
My problem is if I press xradiobutton "a" procedure modelmode() works fine and procAstr=procA($1), however radiobuttons "A", "B", "C" or "D" do not activate procedures procA(), procB() and so on. I have an idea that output of proc is in format that I can not use as the action to execute. But I can not find any other solution to make code simple.
ted
Site Admin
Posts: 6300
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Post by ted »

On the contrary, it works quite normally. When hoc parses the code and sets up the xpanel,
procAstr is empty. It doesn't matter what you do to procAstr after that--the radiobutton's
action has already been specified--"do nothing."
Konstano

Post by Konstano »

Thank you!
Stupid me.
Before your reply I rewrote it in a different way:

Code: Select all

proc modelmode() {local mmode 
   mmode=$1 
   sprint(procAstr, "procA(%d)", mmode) 
   sprint(procBstr, "procB(%d)", mmode) 
   sprint(procCstr, "procC(%d)", mmode) 
   sprint(procDstr, "procD(%d)", mmode) 

   xlabel("") 
   xradiobutton("A", procAstr) 
   xradiobutton("B", procBstr) 
   xradiobutton("C", procCstr) 
   xradiobutton("D", procDstr)   
} 

xpanel("") 
   xlabel("") 
   xradiobutton("a", modelm_one) 
   xradiobutton("b", modelm_two) 
   xradiobutton("c", modelm_three) 
xpanel()
 
But now I can return to the previous version and just define procAstr in the beginning.
Post Reply