[Gambas-user] Wait statements > stack overflow (gb3)

nando nando_f at ...951...
Mon May 10 04:17:22 CEST 2010


If I understand correctly from my Gambas programming experience
and Benoit's comments over the years...
A WAIT inside an event may allow the event to recursively retrigger
if there are new events for that event.

For example:  A button click that does a lot of work.
If you click the button while the work is being performed,
the WAIT 0.1 causes the the Button1_click to happen again (ie recursively).
I've seen this happen in VB too with DOEVENTS

sub Button1_click
...
  FOR
    ...
    WAIT 0.1
    ...
  NEXT
...


What I do to prevent this is:
I use the TAG property of Button1 as protection

sub Button1_click
IF LEN(Button1.TAG) <> 0 THEN RETURN
Button1.TAG = "1"

...
... perform work
...

Button1.TAG = ""
END SUB

This makes Button1_click a singleton.
You can do this also by making Button1.Enable=FALSE but
the button will look disabled...and you may not want that.

You can also do this by using a public boolean
PUBLIC Button1Protect 'false


Sub Button1_click
IF Button1Protect = true THEN RETURN
Button1Protect=true

..do work

Button1Protect = False
END SUB


-Fernando


---------- Original Message -----------
From: richard terry <rterry at ...1946...>
To: mailing list for gambas users <gambas-user at lists.sourceforge.net>
Sent: Fri, 7 May 2010 14:29:55 +1000
Subject: [Gambas-user] Wait statements > stack overflow (gb3)

> Hi LIst,
> 
> I'm automatically parsing many many thousands of pages of documents, the 
> patients are in a listbox, and the documents in another. (with underlying 
> collections of course).
> 
> The basic code looks like this:
> 
> If cvwInboxDocuments.count = 0 Then
>                   '.... do a whole lot of stuff
>       Wait      'make the gui refresh
>   Else
>                    '.... do a whole lot of stuff
>       Wait      'make the gui refresh
> 
>      Wait 
>   End If
> 
> When this runs, it looks at each of the some 1800 pages of documents, 
> generated from hl7 files which were previously  parsed into the table by an 
> automated process and converts the essential info to html  for display, which 
> it resaves and  and does the appropriate linking it needs to do to patient 
> names, provider names, test names etc.
> 
> Though this could all run 'under the hood -automaed', I put the Wait 
> statements in so I could see the lists updating on the screen to watch what 
> was happening.
> 
> If I run the code, after doing about 1/4 of the work it dies on the Wait 
> statement with a 'Stack Overflow' error.
> 
> If I comment out the Wait statements > it all runs without a problem.
> 
> Anyone know what's happening??
> 
> Regards
> 
> Richard
> 
> ------------------------------------------------------------------------------
> 
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
------- End of Original Message -------





More information about the User mailing list