• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 546
  • Last Modified:

"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...
0
wbph
Asked:
wbph
  • 2
  • 2
1 Solution
 
bluecometCommented:
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

http://www.experts-exchange.com/Programming/Programming_Languages/PowerBuilder/Q_20544808.html

I see for the moment only this way to use threads for you.
0
 
SylvainPouliotCommented:
Did you try using the yield() function in your loop?
0
 
wbphAuthor Commented:
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
0
 
SylvainPouliotCommented:
for x = ....

  ..your_code..

  yield()
if cb_stop.enabled = false
  goto stop
end if

next


If you can't make it work, post a part of your function so I can modify it
0
 
wbphAuthor Commented:
thanks for your answer!

i didnt know the yield function but it works great!

thanks!

willem
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now