home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0020 - 0029 / ibm0020-0029 / ibm0028.tar / ibm0028 / BLST10_2.ZIP / SAMPLES / EXAMPLE.MOD < prev    next >
Encoding:
Text File  |  1990-09-13  |  13.5 KB  |  354 lines

  1. :
  2. #########################################
  3. #
  4. # Custom Modem Script
  5. #
  6. # This script template is derived from the AT command set script.
  7. # Please refer to the comments here when writing customized modem scripts.
  8. #
  9. # Areas that will often be customized are indicated by a comment of the form:
  10. #
  11. #-------------------------------------------------------------------------------
  12. # Description of what follows
  13. #-------------------------------------------------------------------------------
  14. #
  15. # Structure of a modem script
  16. #                 
  17. #    1) Optional comments --    any comments preceding the index tag start with a
  18. #                            colon (:) on a line by itself.  This tells the
  19. #                            index program to keep these lines.  If it is
  20. #                            omitted, the leading comments will be lost during
  21. #                            the indexing process.
  22. #    2) Index tag ----------    A colon (:) followed by up to eight charaters.
  23. #                            This is the name to use in the Modem Type field
  24. #                            of the Setup.  Modem Type ignores the case of the
  25. #                            entries in the modems.scr index.
  26. #    3) Entry points    -------    Each entry point returns 0 if successful.
  27. #                            Unsuccessful results are indicated by returning
  28. #                            1 if not running AutoPoll, 
  29. #                            Three entry points are required in a modem script:
  30. #                            .DIAL -----    Makes an outgoing connection thru the
  31. #                                        modem or other media (digital switch,
  32. #                                        mux, X.25).  This entry point is used
  33. #                                        by CONNECT, before calling the .LOGON
  34. #                                        portion of the systems script.  As with
  35. #                                        most BLAST Scripts, a return status of
  36. #                                        0 indicates success, 1 for failure (-1
  37. #                                        when running AutoPoll).  When running
  38. #                                        AutoPoll, modem scripts also update the
  39. #                                        online status screen.  This section of
  40. #                                        the script must initialize the modem,
  41. #                                        make the connection and perform any
  42. #                                        baud rate adjustments, etc.
  43. #                            .ANSWER ---    Waits for an inbound connection.  This
  44. #                                        entry point is also used by CONNECT, but
  45. #                                        only when the Originate/Answer setting
  46. #                                        is ANSWER.  It is generally not used by
  47. #                                        AutoPoll.  The answer section should
  48. #                                        initialize the modem to a known state,
  49. #                                        wait indefinitely for an incoming call
  50. #                                        and make baud rate adjustments, etc.
  51. #                            .HANGUP ---    Forces the link between the computers
  52. #                                        to be terminated.  DISCONNECT calls this
  53. #                                        entry point (after .LOGOFF if a system
  54. #                                        type was specified).  In order to force
  55. #                                        a disconnection, this portion of the
  56. #                                        script must initialize the modem to a
  57. #                                        known state, drop the connection and
  58. #                                        return the modem to a quiet state.
  59. #    4) Terminator ---------    The label ".END".
  60. #
  61. ##############################################################################
  62. #
  63. #-------------------------------------------------------------------------------
  64. # Index tag (change this to the name you want to use in the System Type field) 
  65. #-------------------------------------------------------------------------------
  66. :Custom
  67. #
  68. #       DIAL the remote system
  69. #
  70. .DIAL
  71.     if @USERIF = "1" AND @SCRFILE = "AutoPoll"
  72.         set @SCRLREG = "1"
  73.         cursor 11,0
  74.         put " "
  75.         cursor 11,0
  76.         put "--> "
  77.         cursor 11,15
  78.         put "Dialing"
  79.         set @SCRLREG = "0"
  80.     end
  81.     if not NULL @PHONENO goto .DIAL01
  82.     if @SCRFILE = "AutoPoll"
  83.         fwrite 4, "                  >> CHECK SETUP or SITE FILE - Dial failed: No Phone Number entry"
  84.         if @USERIF = "0" return -1
  85.         set @SCRLREG = "1"
  86.         cursor 11,0
  87.         put " "
  88.         cursor 11,0
  89.         put "   X"
  90.         cursor 11,15
  91.         put "CHECK SETUP or SITE FILE - No Phone Number entry"
  92.         set @SCRLREG = "0"
  93.         return -1
  94.     end
  95.     ask "enter phone number", @phoneno
  96.     if null @phoneno return 0
  97. .DIAL01
  98.     reps 3
  99. .DIAL10
  100.     set @VALUE = "1"                        # VALUE used for return from goto
  101.     goto .ATIN
  102. .DIAL11
  103.     if @STATUS = "0" goto .DIAL20
  104.     if reps goto .DIAL10
  105.     if @SCRFILE not = "AutoPoll" return 1
  106.     fwrite 4, "                  >> CHECK SETUP or local modem - Dial failed: Wrong Modem Type or modem not connected"
  107.     if @USERIF = "0" return -1
  108.     set @SCRLREG = "1"
  109.     cursor 11,0
  110.     put " "
  111.     cursor 11,0
  112.     put "   X"
  113.     cursor 11,15
  114.     put "CHECK SETUP or modem - Wrong Modem Type or modem not connected"
  115.     set @SCRLREG = "0"
  116.     return -1
  117. .DIAL20
  118.     reps 3
  119. .DIAL25
  120. #-------------------------------------------------------------------------------
  121. # Replace the dial command, below
  122. #-------------------------------------------------------------------------------
  123.     tsend "ATDT",@PHONENO,CR
  124. #-------------------------------------------------------------------------------
  125. # Replace the responses, also - the first one should be the successful response
  126. # Of course, the actions taken on the various result codes will also vary from
  127. # one device to another.  Successful connections should procede to .DIALX, where
  128. # any auto baud'ing or cleanup is taken care of.
  129. #-------------------------------------------------------------------------------
  130.     ttrap 45 "CONNECT","NO CARRIER","VOICE","BUSY","NO ANSWER","NO DIAL"
  131.     let @VALUE = @STATUS - "1"
  132.     if @VALUE = "0" goto .DIALX
  133.     if @SCRFILE not = "AutoPoll" goto .DIAL30
  134.     if @VALUE = "1" fwrite 4, "                  * CHECK SETUP or SITE FILE - Dial failed: Wrong number or remote modem config problem (NO CARRIER)"
  135.     if @VALUE = "2" fwrite 4, "                  * CHECK SETUP or SITE FILE - Dial failed: Probable VOICE Phone Number"
  136.     if @VALUE = "3" fwrite 4, "                  * CHECK SETUP or SITE FILE - Dial failed: Phone Number is busy"
  137.     if @VALUE = "4" fwrite 4, "                  * CHECK SETUP, SITE FILE, or remote modem - Dial failed: Modem not answering"
  138.     if @VALUE = "5" fwrite 4, "                  * CHECK LOCAL MODEM and PHONE LINE - Dial failed: No dial tone"
  139.     if @USERIF = "0" goto .DIAL30
  140.     set @SCRLREG = "1"
  141.     cursor 11,15
  142.     put " "
  143.     cursor 11,15
  144.     if @VALUE = "1" put "Wrong number or remote modem config problem (NO CARRIER)"
  145.     if @VALUE = "2" put "Probable wrong Phone Number (VOICE)"
  146.     if @VALUE = "3" put "Busy"
  147.     if @VALUE = "4" put "No answer"
  148.     if @VALUE = "5" put "No dial tone - check Local modem and phone line"
  149.     cleol
  150.     set @SCRLREG = "0"
  151. .DIAL30
  152.     if reps goto .DIAL25
  153. .DIALX
  154.     if @VALUE not = "0" goto .DIALX1
  155. #-------------------------------------------------------------------------------
  156. # If any final clean up, baud rate settings, etc are required, place them here
  157. #-------------------------------------------------------------------------------
  158.     ttrap 2 "1200","2400","4800","9600"
  159.     if 0 set @BAUDRATE = "300"
  160.     if 1 set @BAUDRATE = "1200"
  161.     if 2 set @BAUDRATE = "2400"
  162.     if 3 set @BAUDRATE = "4800"
  163.     if 4 set @BAUDRATE = "9600"
  164. .DIALX1
  165.     if @USERIF = "0" or @SCRFILE not = "AutoPoll" goto .DIALXX
  166.     set @SCRLREG = "1"
  167.     cursor 11, 0
  168.     put " "
  169.     cursor 11, 0
  170.     if @VALUE  = "0"
  171.         put "   *"
  172.         cursor 11,15
  173.         put "Connected"
  174.         cleol
  175.     end
  176.     else put "   X"
  177.     set @SCRLREG = "0"
  178. .DIALXX
  179.     if @VALUE = "0" return 0
  180.     if @SCRFILE not = "AutoPoll" return 1
  181.     fwrite 4, "                  >> Dial failed: REVIEW ABOVE MESSAGES - Unable to make modem connection"
  182.     return -1
  183. #
  184. #       HANGUP the modem
  185. #
  186. .HANGUP
  187.     if @USERIF = "1" AND @SCRFILE = "AutoPoll"
  188.         set @SCRLREG = "1"
  189.         cursor 15,0
  190.         put " "
  191.         cursor 15,0
  192.         put "--> "
  193.         cursor 15,15
  194.         put "Hanging up"
  195.         set @SCRLREG = "0"
  196.     end
  197.     reps 3
  198. .HANG10
  199.     set @VALUE = "2"
  200.     goto .ATIN
  201. .HANG11
  202.     if @STATUS = "0" goto .HANG20
  203.     if reps goto .HANG10
  204.     if @SCRFILE not = "AutoPoll" return 1
  205.     fwrite 4, "                  >> CHECK SETUP and local modem - Hangup failed: Wrong Modem Type or modem not connected"
  206.     if @USERIF = "0" return -1
  207.     set @SCRLREG = "1"
  208.     cursor 15,0
  209.     put " "
  210.     cursor 15,0
  211.     put "   X"
  212.     cursor 15,15
  213.     put "CHECK SETUP and local modem - Wrong Modem Type or modem not connected"
  214.     set @SCRLREG = "0"
  215.     return -1
  216. .HANG20
  217.     reps 3
  218. .HANG21
  219. #-------------------------------------------------------------------------------
  220. # Replace the command below with whatever it takes to break the connection with
  221. # your device.
  222. #-------------------------------------------------------------------------------
  223.     tsend "ATH",CR
  224.     ttrap 5 "OK", "NO CARRIER"
  225.     let @VALUE = @STATUS - "1"
  226.     if @VALUE = "0" goto .HANGX
  227. #
  228.     if reps goto .HANG21
  229. .HANGX
  230. #-------------------------------------------------------------------------------
  231. # Replace this with the commands to return the device to a quiet state.  This
  232. # prevents problems on lines used for incoming and outgoing connections on
  233. # multi-user systems.
  234. #-------------------------------------------------------------------------------
  235.     tsend "ATE0Q1", CR
  236.     if @USERIF = "0" or @SCRFILE not = "AutoPoll" goto .HANGXX
  237.     set @SCRLREG = "1"
  238.     cursor 15,0
  239.     put " "
  240.     cursor 15,0
  241.     if @VALUE = "0"
  242.         put "   *"
  243.         cursor 15,15
  244.         put "Hung up"
  245.         cleol
  246.     end
  247.     else put "   X"
  248.     set @SCRLREG = "0"
  249. .HANGXX
  250.     if @VALUE = "0" return 0
  251.     if @SCRFILE not = "AutoPoll" return 1
  252.     fwrite 4, "                  >> REVIEW MESSAGES ABOVE - Unable to disconnect modems"
  253.     return -1
  254. #
  255. #       ANSWER an incoming call
  256. #
  257. .ANSWER
  258.     reps 3
  259. .ANSW10
  260.     set @VALUE = "3"
  261.     goto .ATIN
  262. .ANSW11
  263.     if @STATUS = "0" goto .ANSW20
  264.     if reps goto .ANSW10
  265.     if @SCRFILE not = "AutoPoll" return 1
  266.     return -1
  267. .ANSW20
  268. #-------------------------------------------------------------------------------
  269. # All that is required here is to wait for the incoming call.  The .INIT part
  270. # of the script is responsible for setting the device to accept incoming calls.
  271. #-------------------------------------------------------------------------------
  272.     ttrap "CONNECT"
  273. #-------------------------------------------------------------------------------
  274. # Once again, make any final adjustments, before returning
  275. #-------------------------------------------------------------------------------
  276.     ttrap 2 "1200", "2400", "4800", "9600"
  277.     if 0 set @BAUDRATE = "300"
  278.     if 1 set @BAUDRATE = "1200"
  279.     if 2 set @BAUDRATE = "2400"
  280.     if 3 set @BAUDRATE = "4800"
  281.     if 4 set @BAUDRATE = "9600"
  282.     return 0
  283. #
  284. # Initialize the modem to a known state
  285. #
  286. .INIT
  287. #-------------------------------------------------------------------------------
  288. # This wait may not be required in all cases, it is a safety measure to prevent
  289. # interference from line noise, external data, etc on some devices
  290. #-------------------------------------------------------------------------------
  291.     wait 2
  292. #-------------------------------------------------------------------------------
  293. # The first command should try to set the device to some recognizable state.
  294. # If possible, attempt to completely initialize the device with this command,
  295. # as it will shorten execution time.
  296. #-------------------------------------------------------------------------------
  297.     tsend "ATE1V1Q0X1S0=1", CR                    # set AT modem to:
  298.                                                 #       echo (E1)
  299.                                                 #       verbose (V1)
  300.                                                 #       nonquiet (Q0)
  301.                                                 #       extended results (X1)
  302.                                                 #       answer on 1st ring (S0=1)
  303. #-------------------------------------------------------------------------------
  304. # Change this to reflect the most likely responses of your device, with the
  305. # successful response first.
  306. #-------------------------------------------------------------------------------
  307.     ttrap 2 "OK","ERROR","NO CARRIER"            # is modem awake ?
  308.     let @STATUS = @STATUS - "1"
  309.     if @STATUS = "0" goto .ATX
  310. #-------------------------------------------------------------------------------
  311. # Unsuccessful attempts should come here.  If there is a more "forceful" way
  312. # to get the device's attention, do that here
  313. #-------------------------------------------------------------------------------
  314.     tsend "+++"                                    # break into cmd mode if online
  315. #-------------------------------------------------------------------------------
  316. # Once again, look for the most likely responses
  317. #-------------------------------------------------------------------------------
  318.     ttrap 2 "OK", "NO CARRIER"                    # awake yet ?
  319.     if @STATUS = "0"                            # nope
  320. #-------------------------------------------------------------------------------
  321. # This is the final, "brute force" sequence to get the device's attention.
  322. #-------------------------------------------------------------------------------
  323.         drop                                    # try drop and raise dtr
  324.         wait 2
  325.         raise
  326.         wait 2
  327.     end
  328. #-------------------------------------------------------------------------------
  329. # Try to init the device again, before giving up
  330. #-------------------------------------------------------------------------------
  331.     tsend "ATE1V1Q0X1S0=1", CR                    # set modem as above
  332. #-------------------------------------------------------------------------------
  333. # Wait for a response
  334. #-------------------------------------------------------------------------------
  335.     ttrap 2 "OK","ERROR","NO CARRIER"            # is modem awake ?
  336.     let @STATUS = @STATUS - "1"
  337.     if @STATUS not = "0" goto .ATXX
  338. .ATX
  339. #-------------------------------------------------------------------------------
  340. # After waking up the device, any additional settings should be made here
  341. #-------------------------------------------------------------------------------
  342. .ATXX
  343. #-------------------------------------------------------------------------------
  344. # In all cases, initialization ends up here, for return to the proper section
  345. # (DIAL, ANSWER, HANGUP) of the script.
  346. # You may add a test for failure (@STATUS not = "0") here, and perform some
  347. # clean up actions, if required.
  348. #-------------------------------------------------------------------------------
  349.     if @VALUE = "1" goto .DIAL11
  350.     if @VALUE = "2" goto .HANG11
  351.     if @VALUE = "3" goto .ANSW11
  352.     goto .HANG11                                # Fail-safe exit
  353. .END
  354.