Page 1 of 1

xradiobutton action with procedure string output

Posted: Wed Aug 01, 2007 12:00 pm
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.

Posted: Wed Aug 01, 2007 4:07 pm
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."

Posted: Wed Aug 01, 2007 4:16 pm
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.