home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 1 / ARM_CLUB_CD.iso / contents / apps / comms / a / docs / FAQs / Zynet / ZynetScrip < prev   
Encoding:
Text File  |  1995-02-06  |  9.1 KB  |  315 lines

  1. #slipdial script for Zynet
  2. #--------------------------------------------------------------------
  3. # Script : Zynet
  4. #
  5. # !SlipDial 0.29 Demon Script - R.W.Orwin 1994 (rob@wong.demon.co.uk)
  6. #                Sprites by James Woodman (woody@bacchus.demon.co.uk)
  7. #
  8. # Revised: Alan Fitch 940627 : note now hardwired to work with USR
  9. #                              modems.
  10. # Revised: Alan Fitch 940629 : to send long modem strings using the
  11. #                              USR driver by quoting them in quotes.
  12. #                              (comment above no longer applies)
  13. # Revised: Alan Fitch 940702 : to rename "hg" to "_pin"
  14. # Revised: Alan Fitch 940708 : to release modem correctly if no prompt
  15. #                              received (e.g. login, password, protocol etc).
  16. # Revised: Alan Fitch 940717 : Newsrate added
  17. # Revised: Alan Fitch 940803 : betanews also calls convmail
  18. # Revised: Alan Fitch 940911 : To use newsbase/ttfn
  19. # Revised: Alan Fitch 940911 : Task killing tidied up.
  20. # Revised: Alan Fitch 940912 : To add Isle of Wight 'phone number
  21. # Revised: Alan Fitch 940926 : TCPIP$dir changed to TCPIP2$dir
  22. # Revised: Alan Fitch 940928 : Removed references to Internet$Dir
  23. # Revised: Alan Fitch 940929 : Stopped using tmstrt, tmend, diff to create a #                              short delay - now fixed to 3 seconds.
  24. # Revised: Alan Fitch 941005 : order of startup of newsbase and TTFN swapped.#                              TTFN must start first for everything
  25. #                              to work properly.
  26. # Revised: Alan Fitch 941117 : to rename sprites to hg_on/hg_off so
  27. #                              standard DemonSpr sprite file will still work
  28. # Revised: Merlyn Kline 950201 : Zynet version
  29. #
  30.  
  31. call initMain
  32. call configure
  33. call setserial
  34. call makemenus
  35. # change following line to "call mercury_on" for default use of mercury
  36. call mercury_off
  37.  
  38. #
  39. # main loop
  40. #
  41. :loop
  42. message /close
  43. wait /event
  44. goto loop
  45. exit
  46.  
  47. # end of program
  48. #--------------------------------------------------------------------
  49.  
  50. #====================================================================
  51. # SUBROUTINES
  52. #====================================================================
  53.  
  54. #-----------------------------------------------------------
  55. #Subroutine: exe
  56. #calls exeter pop: returns via subroutine dodial
  57. #-----------------------------------------------------------
  58. :exe
  59. set phonenum 01392431133
  60. set costband b
  61. goto dodial
  62.  
  63. #-----------------------------------------------------------
  64. # Subroutine: dodial
  65. # Note: has multiple entry points from "goto" statements
  66. # above.  However it finally returns to the main waiting
  67. # loop.
  68. #-----------------------------------------------------------
  69. :dodial
  70.  
  71. #convert any outgoing mail/news
  72. if (?file <Rucp$Dir>.uucp.spool.post.c.*) call convmail
  73. if (?file <Rucp$Dir>.uucp.spool.news.c.*) call convmail
  74. if (?file <Rucp$Dir>.uucp.spool.betanews.c.*) call convmail
  75.  
  76. # Timers to compute the call cost.
  77. set coststrt 0
  78. set costend 0
  79.  
  80. # kill Incorp if it is running, and was started from SlipDial
  81. #task /kill="Incorp"
  82. task /kill="Newsbase"
  83. task /kill="TTFN"
  84.  
  85. # Claim the device driver
  86. if (!claim 3) return 0
  87.  
  88. # initialise modem
  89. init
  90.  
  91. # dial the number, return to main menu if failed.
  92. retry 50 15
  93. if (!dial /nodial=15 /nocar=10 /busy=2 %mercury_pin%phonenum) return 0
  94.  
  95. #
  96. # arrive here if dial succeeded
  97. # get username/password prompts to authenticate self to server.
  98. # after each prompt, return to main menu if failed.
  99. #
  100.  
  101. # initialise timer for call cost
  102. #set coststrt %$time
  103.  
  104. if (!wait /del=20 ogin:) goto bad_finish
  105. send %nodename
  106.  
  107. if (!wait /del=20 word:) goto bad_finish
  108. send %password
  109.  
  110. if (!wait /del=50 ocol:) goto bad_finish
  111. send %protocol
  112.  
  113. #message /capture="IP" /end="HELLO" /maxlines=7 /centre
  114. #ipget 158.
  115. #if (!wait /del=30 HELLO) return 0
  116.  
  117. #wait /delay=10 "a while"
  118. task /name="TCP/IP" <TCPIP2$dir>.!Run
  119.  
  120. # watch out for carrier detect to go low
  121. alarm /dcd "goto good_finish"
  122. :loop2
  123. wait /event
  124. goto loop2
  125.  
  126. #
  127. # Call has been finished successfully, so release the port
  128. #
  129. :good_finish
  130. task /kill="TCP/IP"
  131. message /close
  132. message "Call finished successfully" /centre
  133. release
  134. call costcalc
  135.  
  136. # now pause for 2 seconds to allow RISC OS to sort out the display.
  137. pause 2
  138.  
  139. #
  140. # Compute the news transfer rate, and display it.
  141. #
  142. # This would probably go wrong if the DemNews file still existed from
  143. # a previous call, i.e. old news hadn't been transferred out of the
  144. # Mail$Dir directory.  This shouldn't happen if this script is always used
  145. # as it automatically uses the convmail procedure to move new news into
  146. # ReadNews format.
  147. #
  148.  
  149. # Check if the news file exists.
  150. set newsExists {?file <Mail$Dir>.folder.DemNews}
  151. case %newsExists
  152. when 1 2 3; set nrate {newsrate Dem}; message "news rate %nrate cps" /centre
  153. when 0; message "no news downloaded" /centre
  154. endcase
  155. unset newsExists
  156. unset nrate
  157.  
  158. #
  159. # Following small section is for users of !ReadNews & !Rucp & RN Filters
  160. # <Internet$Dir> should be set to directory where all of above can be found.
  161. #
  162. #task "<Internet$Dir>.ka9q->rucp { > null: }"
  163. #task "<Internet$Dir>.!Incorp.!Run"
  164. task /name="TTFN" <TTFN$Dir>.!Run
  165. task /name="Newsbase" <NewsBase$Dir>.!Run
  166.  
  167. #now trim DemHist File
  168. call trimfile <NNTP$Dir>.DemHist
  169. return 1
  170.  
  171. #
  172. # Call failed in some way
  173. #
  174. :bad_finish
  175. message "Call setup failed" /centre
  176. release
  177. call costcalc
  178. message/close
  179. return 0
  180.  
  181. #-----------------------------------------------------------
  182. # Subroutine: convmail
  183. # Convert mail between rucp and ka9q formats.
  184. # above.  However it finally returns to the main waiting
  185. # loop.
  186. #-----------------------------------------------------------
  187. :convmail
  188. #task "<Internet$Dir>.rucp->ka9q { > null: }"
  189. return 1
  190.  
  191. #-----------------------------------------------------------
  192. # Subroutine: trimfile
  193. # Trim a specified history file.
  194. #-----------------------------------------------------------
  195. :trimfile
  196. if (?lt {?file/size %p1} 5000) return
  197. copy/tail=200 %p1 %p1-T;delete %p1;move %p1-T %p1
  198. return 1
  199.  
  200. #-----------------------------------------------------------
  201. # Subroutine: costcalc
  202. # Compute the cost of the call as far as possible.
  203. #-----------------------------------------------------------
  204. :costcalc
  205. set costend %$time
  206. set costlen {eval "%costend-%coststrt"}
  207. unset costend
  208. return 1
  209.  
  210. #-----------------------------------------------------------
  211. # Subroutine: Mercury
  212. # Toggle the mercury switch
  213. #-----------------------------------------------------------
  214. :mercury
  215. if (?eq %mercury_pin %mercury) goto mercury_off
  216. # Set the Mercury switch to ON.
  217. :mercury_on
  218. icon /id="Mercury" /action="call mercury" hgon
  219. set mercury_pin %mercury
  220. goto mercury_return
  221. # else Set the Mercury switch to OFF.
  222. :mercury_off
  223. icon /id="Mercury" /action="call mercury" hgoff
  224. set mercury_pin ""
  225. :mercury_return
  226. return 1
  227.  
  228. #-----------------------------------------------------------
  229. # Subroutine: makemenus
  230. # Defines the menus for dialling etc.
  231. #-----------------------------------------------------------
  232. :makemenus
  233. menu "Exeter:call exe"
  234. menu /icon="Mercury" "Mercury On:call mercury_on" "Mercury Off:call mercury_off"
  235. return 1
  236.  
  237. #-----------------------------------------------------------
  238. # Subroutine: setserial
  239. # Set Serial Port/Driver Parameters
  240. #-----------------------------------------------------------
  241. :setserial
  242. driver hayes
  243. port %wport %prtnum
  244. speed %speed
  245. set protocol slip
  246. return 1
  247.  
  248. #-----------------------------------------------------------
  249. # Subroutine: setup1
  250. # Called to setup defaults if no configuration file present.
  251. #-----------------------------------------------------------
  252. :setup1
  253. input/prompt="Enter Serial Block Driver Name" wport
  254. input/prompt="Enter Serial Port Number (if relevant)" prtnum
  255. input/prompt="Enter Your Modem->Computer Speed (bps):" speed
  256. input/prompt="Enter Your Zynet Nodename:" nodename
  257. input/prompt="Enter Your Password:" password
  258. input/prompt="Enter Your Mercury PIN:" mercury
  259. open/id=conf/write %filename
  260. write/id=conf %wport
  261. write/id=conf %prtnum
  262. write/id=conf %speed
  263. write/id=conf %nodename
  264. write/id=conf %password
  265. write/id=conf %mercury
  266. close/id=conf
  267. return 1
  268.  
  269. #-----------------------------------------------------------
  270. # Subroutine: configure
  271. # This loads password config from file or prompts for data
  272. # to create file.
  273. #-----------------------------------------------------------
  274. :configure
  275. set filename {?file/expand slipdial:Zynetconfg}
  276. if (!?file %filename) call setup1
  277. open/read/id=conf/error="return" %filename
  278. read/id=conf/eof="goto closeconf" wport
  279. read/id=conf/eof="goto closeconf" prtnum
  280. read/id=conf/eof="goto closeconf" speed
  281. read/id=conf/eof="goto closeconf" nodename
  282. read/id=conf/eof="goto closeconf" password
  283. read/id=conf/eof="goto closeconf" mercury
  284. :closeconf
  285. close/id=conf
  286. return
  287.  
  288. #-----------------------------------------------------------
  289. # Subroutine: initMain
  290. # General initialisation.
  291. #-----------------------------------------------------------
  292. :initMain
  293. # remove comment from following line for tracing
  294. #trace "SlipDial:logoutput"
  295. debug 3
  296. icon /file="SlipDial:ZynetSpr"
  297. set mercury_pin ""
  298. #
  299. # Following lines will have to be setup for your location in the
  300. # country.
  301. #
  302. # Default costband.  Should be adjusted for each menu item which can
  303. # call a number (see subroutine :lon for instance).
  304. set costband b1
  305. return 1
  306.  
  307.  
  308.  
  309.   ------------------------------- CUT HERE ----------------------
  310.  
  311.  
  312. Merlyn (merlyn@zynet.co.uk)
  313.  
  314.  
  315.