home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-03-24 | 700 b | 22 lines | [TEXT/ALFA] |
-
- ( Sample program to read a disk file )
-
- create buff 4096 allot ( only 1st 4k of file )
- create str 80 allot ( name of the file )
-
- : get$ ( -- addr ) ( get the name of a file and return the address )
- cr ." File name ? "
- str 80 expect cr ( get the string )
- 0 str span + c! ( NULL terminated )
- str ; ( return the address of the string )
-
- : readfile ( -- ) ( prompt for a file and read it )
- 0 get$ fopen drop ( open the file, ignore error code )
- 0 buff 4095 fread ( read the file buffer )
- drop ( drop ec and leave actual length read )
- 0 do
- buff i + @ emit ( print a character )
- loop
- 0 fclose drop ; ( close the file )
-
-