> From: "Carl A. Helber" <cahelber_at_uswest.net>
>
> So far I haven't been able to understand how to read an arbitrary
> file (midi music in this case) to a selected area in memory. I know
> this is probably inefficient and inelegant but I set up a variable
> at <HERE> with a large allot value. I want to read a file into this
> buffer for further manipulation. I have been using this program from
> F83 days and would like to modify it for use in SwiftForth.
Try this:
: READ ( -- addr len )
BL WORD COUNT R/W OPEN-FILE THROW >R
PAD CELL+ 50000 R@ READ-FILE ( nread ior) SWAP PAD !
R> CLOSE-FILE THROW THROW PAD @+ ;
It will read a file up to 50000 bytes to the space above pad, then
return the length acutally read and the address where to access it.
-- Rick VanNorman rvn_at_forth.com .Received on Sun Oct 24 1999 - 21:33:53 PDT
Subscribe to our e-mail list service. It's free for all SwiftForth and SwiftX users!
This archive was generated 08-Feb-2012. Archive updated nightly.