On Mon, 3 Dec 2001 10:51:02 -0800, you 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 )=20
> DUP ROT R@ READ-FILE THROW ( bytes-read )
> R> CLOSE-FILE THROW ;
>
>: TEST ( -- ) \ Display file contents
> S" myfile.txt" FILE>MEM ( MemAddress FileSize )=20
> CR 2DUP TYPES ( Display File Contents )=20
> DROP ( discard size )=20
> FREE THROW ( Release Memory - we must do this! ) ;
>
>
>Note that TYPES is a version of TYPE that handles line feeds etc.
>
>Mike
What to do if extension is bin, S" myfile.bin"?
Thanks.
=20
Damir
----------------------------------------------------------------------
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 Sat Jan 12 2002 - 11:05:50 PST
Subscribe to our e-mail list service. It's free for all SwiftForth and SwiftX users!
This archive was generated 09-Feb-2012. Archive updated nightly.