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 ?

How to break for() use a button ?

Discuss OrbForms Designer and PocketC Architect

Postby Main Chen on Thu Jan 09, 2003 9:54 pm

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;
}
Main Chen
 
Posts: 22
Joined: Tue Jul 30, 2002 10:52 am

Postby jfield on Thu Jan 09, 2003 11:13 pm

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.
jfield
 
Posts: 43
Joined: Sun May 13, 2001 1:36 am
Location: USA

Postby samps on Thu Jan 09, 2003 11:41 pm

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
Ubuntu user #82
samps
 
Posts: 143
Joined: Tue Feb 20, 2001 12:33 am
Location: Australia

Postby cao on Fri Jan 10, 2003 4:17 am

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.
cao
 
Posts: 60
Joined: Tue Dec 05, 2000 4:11 am
Location: USA

Postby samps on Fri Jan 10, 2003 5:57 am

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
Ubuntu user #82
samps
 
Posts: 143
Joined: Tue Feb 20, 2001 12:33 am
Location: Australia

Postby cao on Fri Jan 10, 2003 4:34 pm

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.
cao
 
Posts: 60
Joined: Tue Dec 05, 2000 4:11 am
Location: USA

Postby Main Chen on Mon Jan 13, 2003 4:35 am

<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.
Main Chen
 
Posts: 22
Joined: Tue Jul 30, 2002 10:52 am

Postby dewey on Mon Jan 13, 2003 8:23 pm

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.
dewey
Site Admin
 
Posts: 749
Joined: Sun Oct 21, 2007 5:12 am


Return to OrbForms Designer and PocketC Architect

Who is online

Users browsing this forum: No registered users and 1 guest

cron