programming tools for Windows applications development
  Home  |   SwiftForth Archive  |   SwiftX Archive  |

Re: SwiftForth's default CATCH/THROW behavior WAS Re: File to memory and memory to file allot + mem to swiftforth

From: Elizabeth D. Rather <erather_at_forth.com>
Date: Mon, 03 Dec 2001 13:45:08 -0800

At 03:18 PM 12/3/01 -0600, you wrote:

>Mike Ghan wrote:
> >
> > An example of file access and memory allocation:
> >
> > \ Use S" filename.ext" FILE>MEM
> > : FILE>MEM ( filename count -- memAddr filesize )
> > R/O OPEN-FILE THROW >R
> > R@ FILE-SIZE THROW D>S ( size )
> > DUP ALLOCATE THROW ( Allocate a Memory Block )
> ><SNIP>
>
>Looking at this and Section 4.7 of _Users' Manual_ seems to indicate I
>would not have to write my own CATCH routine for the above code to work.
>I don't have any doubt about when operating in the terminal window.
>
>What happens in a turnkey application, explicitly one built around
>GENERICWINDOW and relatives?

The default behavior applies to errors caught by the system. If your
application CATCHes an error, you completely control how you handle
it. Typically you want to CATCH the highest-level word in your
application, and may CATCH any word that has a possible error condition
you'd like to be able to detect and handle. Following the CATCH, an error
code (0=no error, non-zero identifies the error) is on the stack. You can
examine it and respond appropriately. Any error you don't wish to handle
can be THROWn to a higher-level CATCH. Ideally your app should test for
any anticipated errors (e.g. user enters a bad value), and you should test
it sufficiently to know there won't be any unanticipated ones (e.g. stack
empty).

Cheers,
Elizabeth

================================================
Elizabeth D. Rather (US & Canada) 800-55-FORTH
FORTH Inc. +1 310-491-3356
5155 W. Rosecrans Ave. #1018 Fax: +1 310-978-9454
Hawthorne, CA 90250
http://www.forth.com

"Forth-based products and Services for real-time
applications since 1973."
================================================

----------------------------------------------------------------------
sftalk_at_forth.com The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe sftalk" to listar_at_forth.com
For help with listar commands, send subject "help" to listar_at_forth.com
Archives are located at http://www.forth.com/sftalk -- check them out!
Search the archives! Visit http://www.forth.com/search for details.
Received on Mon Dec 03 2001 - 13:52:39 PST

This archive was generated by hypermail 2.2.0 : Fri Nov 21 2008 - 03:04:20 PST