home *** CD-ROM | disk | FTP | other *** search
- /*
- ** A simple beginning of a toy terminal using FIFO and sercli.
- **
- ** The idea was simple, and simply executed:
- ** Open a local NewCON: window for getting LOCAL user input
- ** Open a log file to indicate what happened during the execution
- ** until the user quits
- ** get a block of text from the FIFO (currently up to 4k --
- ** generally, however much is out there)
- **
- ** Log the text with a trailing FormFeed character so that it can
- ** be parsed later (bad choice, since FormFeeds may often be used
- ** by BBSses to clear screens).
- **
- ** Prompt the user for a response. The response must begin with a
- ** `quit (', `continue (', or `respond (' string (case
- ** INsensitive). Other than that, the command can be anything; a
- ** `CMD_' string is directly concatenated to the front of the user
- ** response, and then the whole is passed through the INTERPRET
- ** instruction -- thus the response can effectively be a whole
- ** ARexx program on a line.
- ** NOTE: The _remote_'s text is available through the variable
- ** TEXT whenever you are prompted for a response; you should
- ** be able to construct a `response command' that uses parts
- ** of the BBS information (e.g., when doing messages, you
- ** would want to respond by sending the message to a message
- ** file).
- **
- ** The user's response is also logged, and is also terminated with
- ** a formfeed.
- **
- ** Thus, at the end, one has a log file describing all of the `remote
- ** events', and all of the `local responses'. It should be
- ** straightforward to use this information to generate a script for a
- ** given BBS.
- **
- ** Arbitrary additional commands may be added.
- **
- ** One thing I was planning on doing was to arrange for timeouts to be
- ** observed when reading serial input; thus one could do serial input,
- ** spewing long, multi-screen messages to a temporary file, and ONLY try
- ** to make a `decision' when the data stopped flowing for more than a
- ** couple of seconds. This could be done by beefing up sercli a lot, or
- ** possibly by simply recoding for another terminal, such as VLT. I was
- ** planning on doing it from ARexx by running a seperate ARexx script to
- ** do input, and another to provide 1-second `ticks', then monitor a
- ** message port to which each would send data; if <N> consecutive ticks
- ** come in with no intervening data, we do a timeout event; if data comes
- ** in, we zero the tick count & process the data. (In fact, I've done
- ** something similar elsewhere -- it _is_ a little hairy, but it still has
- ** a certain appeal...)
- **
- ** Rather than using a FormFeed to terminate each section of input, I
- ** would suggest prefixing the section with a length, or creating an
- ** independant index file.
- **
- ** NOTE:
- ** HARD_CODED_MODEM_COMMAND is sent when this script starts up.
- ** Originally, I had selected a guinea pig BBS and made dialing it the
- ** first thing the script did.
- **
- ** NOTE ALSO:
- ** The NewCON: window does NOT exist under v2.0. However, using CON:
- ** would throw away command line history & most command line editing
- ** under v1.3. Since I having used this command in a long time & only
- ** upgraded from v1.3 recently, I have not changed this.
- **
- ** NOTE FURTHER:
- ** There is no ^C-^F handling installed; be careful, or add some...
- ** (I don't think the CON: window sends BREAKs when in RAW mode; since
- ** FIFO controls RAW mode for sercli, there's not much I can do about
- ** it...)
- **
- ** NOTE LASTLY:
- ** This program ASSUMES it is talking to a sercli with an ARexx port
- ** named `rkr'; the sercli window title bar is used to post certain
- ** messages (mostly used for isolating problems, as I recall).
- **
- */
- options results
- address 'rkr' "window size: 640 10"
- eol = '0d'x
-
- /* HARD_CODED_MODEM_COMMAND = 'ATD 469 4401'eol */
- HARD_CODED_MODEM_COMMAND = 'ATZ'eol
-
- if ~open( log, "mail.log", 'a' ) then do
- exit( 0 )
- end
- x = title( 'log file open.' )
-
- if ~open( usr, "newcon:0/0/640/100/userinput", r ) then do
- exit( 0 )
- end
- x = title( 'user input open...' )
-
- address command "set_raw"
- x = title( 'DOS RAW mode on.' )
-
- x = writech( stdout, HARD_CODED_MODEM_COMMAND )
- x = title( 'Dialing' )
-
- valid_cmd. = 0
- valid_cmd.quit = 1
- valid_cmd.continue = 1
- valid_cmd.respond = 1
-
- x = title( 'main loop...' )
- done = 0
- do while ~done
- text = readch( stdin, 4096 )
- x = writech( log, text )
- x = writech( log, '0c'x )
- x = writech( usr, '{'text'} ' )
- cmd = ''
- do while ~valid_cmd.cmd
- x = writeln( usr, cmd 'Response?' )
- rsp = readln( usr )
- parse value rsp with cmd '('
- cmd = upper( cmd )
- end
- x = writech( log, rsp'0c'x )
- cmd = 'cmd_'rsp
- interpret( 'x =' cmd )
- end
-
- delay( 5 )
-
- /*** address command "set_con" ***/ /*** not needed... ***/
-
- exit( 0 )
-
-
- title:
- parse arg new_title
- address 'rkr' 'window title:' new_title
- return result
-
-
- cmd_quit:
- done = 1
- writeln( usr, "Quiting..." )
- return 0
-
-
- cmd_continue:
- writeln( usr, "Continuing..." )
- return 0
-
-
- cmd_respond:
- parse arg text
- return writech( stdout, text )
-