home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / f / forthmac / !Forthmacs / lib / modem+ < prev    next >
Encoding:
Text File  |  1997-01-19  |  1.1 KB  |  34 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.  
  12. : m-cr    carret m-emit ;
  13. : m-".    count m-type ;    ( str -- )    \ write a line to modem
  14. : remember-m-key    ( key -- key )
  15.     m-in-buffer dup char+ swap h# 10  cmove
  16.     dup m-in-buffer [ buff-len 1- ] literal + c! ;
  17. : received-string?    ( str -- flag )
  18.     count m-in-buffer buff-len + ( addr1 count end-addr )
  19.     over - swap comp 0= ;
  20. : string-found?        ( key -- key )    \ set flag
  21.     modem-string received-string? if found? on then ;
  22. \ redefinition of m-key
  23. : m-key            ( -- char )
  24.     m-key remember-m-key
  25.     finding? @ if string-found? then ;
  26.  
  27. \ wait for a string from the modem
  28. : string-wait    ( str msec -- true )    \ waits msec for string str to appear
  29.     finding? on  found? off swap modem-string "copy
  30.     m-in-buffer h# 10 erase
  31.     0 ?do 100 ms  found? @ if leave then  100 +loop
  32.     found? @ finding? off ;
  33. only forth also definitions
  34.