Link to home
Start Free TrialLog in
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...
Avatar of bluecomet
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.
Did you try using the yield() function in your loop?
Avatar of 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
ASKER CERTIFIED SOLUTION
Avatar of SylvainPouliot
SylvainPouliot

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wbph

ASKER

thanks for your answer!

i didnt know the yield function but it works great!

thanks!

willem