home *** CD-ROM | disk | FTP | other *** search
/ ftp.uni-stuttgart.de/pub/systems/acorn/ / Acorn.tar / Acorn / acornet / dev / forth / forthmacs / serial / serial~ / !Forthmacs.lib.modem+ < prev    next >
Text File  |  1995-01-26  |  1KB  |  35 lines

  1. \ portable file definining modem extensions HS 01.07.94
  2.  
  3. \needs modem cr .( Load xxx.modem before this! ) abort
  4. only forth also modem also definitions decimal
  5.  
  6. h# 10 constant buff-len
  7. create m-in-buffer    buff-len allot
  8. create modem-string    buff-len  4 + allot
  9. variable found?
  10. variable finding?
  11. create 11-command    h# 20 allot
  12.  
  13. : m-cr    carret m-emit ;
  14. : m-".    count m-type ;    ( str -- )    \ write a line to modem
  15. : remember-m-key    ( key -- key )
  16.     m-in-buffer dup 1+ swap h# 10  cmove
  17.     dup m-in-buffer [ buff-len 1- ] literal + c! ;
  18. : received-string?    ( str -- flag )
  19.     count m-in-buffer buff-len + ( addr1 count end-addr )
  20.     over - swap comp 0= ;
  21. : string-found?        ( key -- key )    \ set flag
  22.     modem-string received-string? if found? on then ;
  23. \ redefinition of m-key
  24. : m-key            ( -- char )
  25.     m-key remember-m-key
  26.     finding? @ if string-found? then ;
  27.  
  28. \ wait for a string from the modem
  29. : string-wait    ( str msec -- true )    \ waits msec for string str to appear
  30.     finding? on  found? off swap modem-string "copy
  31.     m-in-buffer h# 10 erase
  32.     0 ?do 100 ms  found? @ if leave then  100 +loop
  33.     found? @ finding? off ;
  34. only forth also definitions
  35.