home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / language / forst / appfilin.s < prev    next >
Encoding:
Text File  |  1993-10-23  |  1.0 KB  |  47 lines

  1. ( appfilin.s: basic application file input)
  2.  
  3. decimal
  4.  
  5. : openerror
  6.   cr ." could not open the file" cr
  7.   appabort
  8. ;
  9. : closeerror
  10.   cr ." could not close the file" cr
  11.   appabort
  12. ;
  13. : open
  14.   a7 dec w!  a7 dec !  61 a7 dec w!  gemdos
  15.   d0 d0  ( 2 copies of result)
  16.   8 addto a7
  17.   ( result)  0< if openerror then
  18. ;
  19. : openfile  { 5 regs  offset end start length extension }
  20.  
  21.   -128 a5 + to start  start c@  to length
  22.    start length + 1+  to end  end to offset
  23.    0 to extension  ( no .XXX)
  24.    
  25.   for length
  26.     offset dec c@  [ascii] . =  if 1 to extension leave then
  27.   next
  28.   
  29.   extension if
  30.     offset 4 + end - to length
  31.     for length   32 end inc c!  next  ( pad with spaces)
  32.   then
  33.   
  34.   start 1+ 2 open ( file name in base page)
  35. ;  
  36.  
  37. : close  a7 dec w! ( handle)  62 a7 dec w!  gemdos
  38.   d0  ( save result)  4 addto a7
  39.   ( result) 0<  if closeerror then
  40. ;
  41. : read  swap  ( ^buffer to top)
  42.   a7 dec ! ( ^buffer)  a7 dec ! ( #chars)
  43.   a7 dec w! ( handle)  63 a7 dec w!  gemdos
  44.   d0 ( #chars read)
  45.   12 addto a7
  46. ;
  47.