[Gambas-user] Control Groups-bug?

Benoit Minisini gambas at ...1...
Thu Apr 1 00:04:04 CEST 2004


On Sunday 28 March 2004 12:24, Sebastian Jauch wrote:
> Hello,
>
> i found some strange behaviour when running through a control group, i
> sometimes want multiple items to be check or only one (depending on the
> state of cbMultiple.Value
>
> now without the line "IF ($cbAnswers[i]=LAST) THEN CONTINUE"
> gambas enters the debugger, shows a lot of weired variables
> things like "swer.click" ...
> adding the line "IF ($cbAnswers[i]=LAST) THEN CONTINUE" makes everything
> work fine $cbAnswers is a global variable which contains all the checkboxes
> of group "cbAnswer", it seems that whenn i do $cbAnswers[i].Value=false
> withe the LAST item the LAST variable gets horribly corrupted ??
>
> items of $cbAnswers are initialized with:
>
>      tempObject=NEW checkbox(ME) AS "cbAnswer"
>      $cbAnswers.Add(tempObject)
>
> is there some mistake in my code?
> -------
> code that crashes when clicking on a checkbox of group cbAnswer
>
> PUBLIC SUB cbAnswer_Click()
>   DIM i AS Integer
>   DIM cbTemp AS Checkbox
>
>   IF NOT cbMultiple.Value THEN
>      FOR i=0 TO $cbAnswers.Length-1
>         cbTemp=$cbAnswers[i]
>         cbTemp.Value=FALSE
>      NEXT
>      cbTemp=LAST
>      cbTemp.Value=TRUE
>   END IF
> END

By trying your code, I get a "stack overflow" error, not a crash. Which 
version of gambas do you use ?

Note that changing the value of a checkbox raises an event, and so change the 
value of LAST (this behaviour may change in the future). So cbAnswer_Click is 
called recursively until the stack is full.

Regards,

-- 
Benoit Minisini
mailto:gambas at ...1...




More information about the User mailing list