Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3368: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3370: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3371: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3372: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
OrbWorks Community Forum • View topic - How to break for() use a button ?
Page 1 of 1

PostPosted: Thu Jan 09, 2003 9:54 pm
by Main Chen
Hi,

How to break for() use a button ?
I try the source, It can't run,
Thank you!

------------------------->

bool StopFind;

handler FindListForm.onopen() {
StopFind = false;
}

handler FindListForm.ondraw() {
int i;
StringList List;

for(i=0; i<10000; i++) {
if(StopFind) break;
List.add(i);
}
}

handler StopFindBtn.onselect() {
StopFind = true;
}

PostPosted: Thu Jan 09, 2003 11:13 pm
by jfield
Running a for loop and/or running the Form.ondraw method may be higher priority than, or just have to finish before, the Button.onselect method.

P.S.
In your code i is an integer, but the StringList.add method expects a string.

PostPosted: Thu Jan 09, 2003 11:41 pm
by samps
Quote:
"P.S.
In your code i is an integer, but the StringList.add method expects a string."

Doesn't matter.
One of the greatest strengths of Orbforms D and PocketC is the automatic typecasting. (And the addition of the string type to C of course :-)

cheers
Samps

PostPosted: Fri Jan 10, 2003 4:17 am
by cao
Hi Main Chen:

ondraw handler is called when the form wants to draw the items on the screen. It is not designed to do the main algorithm or find operation. You should do the computation work somewhere else.

If you felt the computation can take a long time, you need to look into use a timer or event, and break up the length computation.

This is just a suggestion, i use this approach to implement a stop button in a length computation on the device.

For example:

bool bPause = false; /* define this variable somewhere */

handler btnFindStart.onselect() {
bPause = false;
mainForm.timer(10);
}

handler btnFindStop.onselect() {
bPause = true;
}

mainForm.ontimer() {

/* do a small chunk of find operation. For example: just search a N records */
/* if no pause, continue the timer to cause the find operation to search next N records. */
if (false==bPause) { timer(10); }
}

let me know if this approach works for you.
Thanks.

PostPosted: Fri Jan 10, 2003 5:57 am
by samps
It doesn't work to stop a FOR-loop tho'


Try this:


int i, stopped;

btnStart.onselect()
{
for (i=1;i<1000;i++)
if (stopped!=1)
Label.text=i;
}

btnStop.onselect()
{
stopped=1;
}

btnStart starts the show,Label shows i's from 1 to 999 no matter how many times you click btnStop.

Maybe there's a need for something like the Delphinian Application.ProcessMesages, to make sure that applications keep an eye out for button clicks and the like, even while they're busy doing other stuff.

cheers
Samps

PostPosted: Fri Jan 10, 2003 4:34 pm
by cao
Samps:

Your example doesnot capture my suggestions.

It does not use ontimer() mechanism. Compare your code and my example, I don't see anywhere you used ontimer.
I suggested to break up the lengthy loop to smaller one. Your example still have this one long loop 1->10000

for (i->10000) can be break up into smaller steps.
1-100
101-200
201-300

It gives the UI a chance to accept user input.

PostPosted: Mon Jan 13, 2003 4:35 am
by Main Chen
<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">
let me know if this approach works for you.
<hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote">

Hi Cao

I try the code, it's Ok!
Thank you very much.

PostPosted: Mon Jan 13, 2003 8:23 pm
by dewey
Event handlers are called one at a time - if you put a long computation into one handler, no other handler is able to run until the previous handler completes. This is why Kevin's suggestion of using the timer event to process a small chunk of algorithm is so appropriate.