[comp.lang.pascal] Catch & Throw, how are they used?

wolf@phantasm (05/23/91)

I have recently begun to get my feet wet, in 100 ft.
deep water, with Windows programming.  I am not too
sure what Catch() and Throw() API functions are used
for?

What do these two functions actually do for the programmer?

I'm using Turbo Pascal for Windows and using their API manual
for reference.

--

Also I have a dilemma. I am only designing right now, but have
been looking through the API functions to get an idea of
implementation.  Specifically, I am working on a communications
application (serial communications), and as groups of characters
are received, I want to see if a given set fo strings has been
matched by the incoming characters.  I have designed the part that
handles the receipt of incoming characters, and also that performs
the string comparisons and sets "matched" flags that can be checked
later.  Okay, now I'm at the "later" -- I need to implement a 
waiting loop something like this ->

    while (no strings are matched) do nothing
    act_upon_the_match()

Now I know that Windows is cooperative multitasking and not
pre-emptive.  So, I don't want to tie everything up by having
a loop like this that will not relinquish control back to the
main event loop, and thus onto other processes.  In fact, it
seems that it may in fact halt my message processing loop, upon
which it is contingent (processing rx'd chars from the serial
port).  What is the best way to accomplish this task, besidea
using a timer and setting up polling mechanisms?  The timer
route would cause a tremendous amoutn of overhead maintaining
data across asynchronous calls.  I want one function/method/procedure
to set the match strings up, and wait for one to come true, and then
act upon that one that comes true first.

I have looked thru the API reference and I see Yield(), Catch(),
and Throw(), which on the surface of their infinitely brief descriptions
seem like they may solve my problem.  But...I dunno what they REALLY do.

I'm REALLY stuck here and would appreciate any and all ideas...

Thanx in advance.  I will post a summary of info I receive.

..

Wayne Wolf
Usenet: ...!ingr!wyle!phantasm!wolf
Interner: wyle!phantasm!wolf@ingr.com