Avatar of wbph
wbph
 asked on

"program not responding" while using FOR...NEXT

Hey everybody!

I´m writing a program that controls a machine using serial communication. I have to send coördinates taken from a excel document true the serial port. This all works fine but i have to insert a STOP button. My problem is powerbuilder can´t detect wether i´m pressing the button or not.
i think this is because i am using an FOR..NEXT statement.

let me explain:
the program can be busy in the FOR..NEXT statement for about an hour...while the machine isn´t ready it keeps sending coördinates. during that time the program is only looping in ONE statement. in my statement i have used the script

if cb_stop.enabled = false
   goto stop
end if

but i can´t press the stop button because powerbuilder is too busy looping the FOR..NEXT statement..

is there any solution for this problem??

Thanks in advance

willem hagen

ps. I hope i´ve made my problem clear but it´s very hard to describe for me in english...
Editors IDEs

Avatar of undefined
Last Comment
wbph

8/22/2022 - Mon
bluecomet

Hi wbph,

i am working also on a solution where one application uses thread and where when is needed, any object has his only process time.
So imagine that you have an thread (process) for sending cordinates and one thread where you can all times stop the script.

Refer you on this question for maybe mor explanation

https://www.experts-exchange.com/questions/20544808/Shared-Object-and-Threads.html

I see for the moment only this way to use threads for you.
SylvainPouliot

Did you try using the yield() function in your loop?
wbph

ASKER
i have read about the yield function in the powerbuilder help...

but how do i have to use it...
I have the start and stop button in de same window(the start button is the one with the for..next statement)

thanks,

wbph
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
ASKER CERTIFIED SOLUTION
SylvainPouliot

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
wbph

ASKER
thanks for your answer!

i didnt know the yield function but it works great!

thanks!

willem