home *** CD-ROM | disk | FTP | other *** search
/ Computerworld Gratis 30 Hours of Connection / Image(2).iso / infovia / win31 / genteach.st_ / genteach.st
Text File  |  1995-07-27  |  25KB  |  848 lines

  1. <* 
  2. *>
  3. :(mm,#!,())
  4. :(o,,(
  5. <***************************************************************>
  6. <* GENTEACH.STP - WTN Teach Mode Script                        *>
  7. <*                                                             *>
  8. <* Revision History                                            *>
  9. <* ----------------------------------------------------------- *>
  10. <* 26-MAR-95 (TMG) - Initial coding.  Vanilla teach mode       *>
  11. <*                   "Alpha READY"                             *>
  12. <*                                                             *>
  13. <* Needed Functionality/Known Limitations:                     *>
  14. <*                                                             *>
  15. <* 1. If user enters incorrect username or password the first  *>
  16. <*    time there is currently no way to change it without      *>
  17. <*    restarting WTNVT.  This is half my problem and half      *>
  18. <*    WNVT's.  Maybe an option to wipe the password would fix  *>
  19. <*    this.                                                    *>
  20. <*                                                             *>
  21. <* 2. If user sends a logout command to the server or if the   *>
  22. <*    user selects disconnect, the Trac interpretter is killed *>
  23. <*    and the user is not given the option to save his/her     *>
  24. <*    script.                                                  *>
  25. <*                                                             *>
  26. <* 3. Prompt parser seems to incorrectly parse prompt in a few *>
  27. <*    instances.  This is 99% reliable and should be OK for    *>
  28. <*    Alpha.                                                   *>
  29. <*                                                             *>
  30. <* 4. Would be nice if user could manual go back and edit      *>
  31. <*    prompts/responses visually.                              *>
  32. <*                                                             *>
  33. <* 5. Start over button should be implimented which            *>
  34. <*    disconnect/reconnects.                                   *>
  35. <*                                                             *>
  36. <* 6. Prompt recognition needs to be re-written to support     *>
  37. <*    fuzzy logic.  Things also need to become less lock-step. *>
  38. <*    Maybe beta 2 timeframe?                                  *>
  39. <*                                                             *>
  40. <***************************************************************>
  41. ))
  42.  
  43.  
  44. :(s,teach.)    :(o,,<* My home *>)
  45.  
  46. :(mm,#!,(    :(o,,<* Intercept TRAC responses *>)
  47. ))
  48.  
  49. :(o,,(
  50. <***********************************************************************>
  51. <* Tell user about teach mode. Then prompt user for the default values *>
  52. <* for maximum timeout and the default host prompt character.          *>
  53. <***********************************************************************>
  54. ))
  55.  
  56.         :(s,timer,30000)   <* initialize timer to 30 seconds           *>
  57.         :(s,time_seconds,:(aq,:(r,timer),1000))  <* convert to seconds *>
  58.         :(d,default_prompt)                      <* set default prompt *>
  59.         :(s,default_prompt,>:(bxo,20))           <* to '> '            *>
  60.         :(d,welcome_msg)
  61.  
  62. :(s,welcome_msg,(Welcome to TNVT Teach Mode!
  63.  
  64. Use Teach mode to "teach" TNVT how to connect to and respond to prompts from the remote host.
  65.  
  66. To get started, the Prompt dialog box will ask you for information, first about the maximum timeout and then for the default host prompt.
  67.  
  68. To change the maximum timeout or default prompt:
  69. Select from the list at the bottom of the dialog box and choose OK.
  70.                                              --or--
  71. Enter a new value in the text field and then choose OK.
  72. ))
  73.  
  74.         :(win_message,:(r,welcome_msg)) 
  75.  
  76.          <* ask user to define the maximum time to wait *>
  77.         :(s,time_seconds,
  78.         :(win_prompt,
  79. (Maximum timeout default is shown below. Please confirm or change:),,
  80.            :(r,time_seconds),:(r,time_seconds),(60),(120))
  81. )
  82.  
  83.         <* ask user to define the user prompt to look for on the host *>
  84.         :(s,default_prompt,
  85.         :(win_prompt,
  86. (Default host PROMPT is shown below. Please confirm or change:),,
  87.            :(r,default_prompt),:(r,default_prompt),(# ),(% ))
  88. )
  89.  
  90.  
  91. :(o,,(
  92. <**********************>
  93. <* Build key value db *>
  94. <**********************>
  95. ))
  96. :(mm,teach.loadkeys,(
  97.     :(d,<0>)
  98.     :(s,teach.keys.)
  99.  
  100.     <* Control Keys *>
  101.     :(<0>2,(Carriage Return),(<Enter>))
  102.     :(<0>2,(Escape),(<ESC>))
  103.     :(<0>2,(NUL),(<NUL>))
  104.     :(<0>2,(BEL),(<BEL>))
  105.     :(<0>2,(BS),(<BS>))
  106.     :(<0>2,(Line Feed),(<LF>))
  107.     :(<0>2,(Form Feed),(<FF>))
  108.     :(<0>2,(DEL),(<DEL>))
  109.  
  110.     <* PC Keys *>
  111.     :(<0>2,(CapsLock),(<CapsLock>))
  112.     :(<0>2,(NumLock),(<NumLock>))
  113.     :(<0>2,(ScrollLock),(<ScrollLock>))
  114.     :(<0>2,(Shift),(<Shift>))
  115.     :(<0>2,(Control),(<Control>))
  116.     :(<0>2,(Alt),(<Alt>))
  117.     :(<0>2,(Ignore key),(<Ignore key>))
  118.     :(<0>2,(Reboot),(<Reboot>))
  119.     :(<0>2,(Print Screen),(<Print Screen>))
  120.     :(<0>2,(Toggle Print),(<Toggle Print>))
  121.  
  122.     <* F Keys *>
  123.     :(pc,(
  124.         :(<0>2,(F):(pn):(e,:(pn),15,( ):(tca,41)(Help):(tca,40))
  125.             :(e,:(pn),16,( ):(tca,41)(Do):(tca,40))
  126.         ,(<F):(pn)(>))
  127.     ),20,1)
  128.  
  129.     <* Shift-F Keys *>
  130.     :(pc,(
  131.         :(<0>2,(Shift F):(pn),(<Shift F):(pn)(>))
  132.     ),14,6)
  133.     :(<0>2,(Up Arrow),(<Up Arrow>))
  134.     :(<0>2,(Down Arrow),(<Down Arrow>))
  135.     :(<0>2,(Right Arrow),(<Right Arrow>))
  136.     :(<0>2,(Left Arrow),(<Left Arrow>))
  137.     :(<0>2,(Find),(<Find>))
  138.     :(<0>2,(Insert Here),(<Insert Here>))
  139.     :(<0>2,(Remove),(<Remove>))
  140.     :(<0>2,(Select),(<Select>))
  141.     :(<0>2,(Prev Screen),(<Prev Screen>))
  142.     :(<0>2,(Next Screen),(<Next Screen>))
  143.     :(pc,(
  144.         :(<0>2,(PF):(pn),(<PF):(pn)(>))
  145.     ),4,1)
  146.     :(pc,(
  147.         :(<0>2,(Keypad ):(pn),(<Keypad ):(pn)(>))
  148.     ),10,0)
  149.     :(<0>2,(Keypad .),(<Up Arrow>))
  150.     :(<0>2,(Keypad Enter),(<Up Arrow>))
  151.     :(<0>2,(Keypad ,),(<Up Arrow>))
  152.     :(<0>2,(Keypad -),(<Up Arrow>))
  153.     :(<0>2,(Backspace),(<Backspace>))
  154.     :(<0>2,(Delete),(<Delete>))
  155.     :(<0>2,(Compose Key),(<Compose Key>))
  156.     :(<0>2,(Up Arrow),(<Up Arrow>))
  157.     
  158.  
  159.     :(d,<0>2)
  160. ))
  161.  
  162. :(o,,(
  163. <********************************>
  164. <* Key value builder part Deuce *>
  165. <********************************>
  166. ))
  167. :(mm,teach.loadkeys2,(
  168.     :(s,teach.keys.num,:(aa,0:(r,teach.keys.num),1))
  169.     :(s,teach.keys.k:(r,teach.keys.num),(<1>))
  170.     :(s,teach.keys.v:(r,teach.keys.num),(<2>))
  171. ))
  172. :(teach.loadkeys)   :(o,,<* Fill key database and chuck loader *>)
  173.  
  174. :(o,,(
  175. <*******************************************************>
  176. <* Build db of default prompts and suggested responses *>
  177. <*******************************************************>
  178. ))
  179. :(mm,teach.loadprompts,(
  180.     :(d,<0>)
  181.     :(s,teach.prompts.)
  182.     :(<0>2,(login:),6,y)
  183.     :(<0>2,(username:),6,y)
  184.     :(<0>2,(userid:),6,y)
  185.     :(<0>2,(id:),6,y)
  186.     :(<0>2,(password:),7,y)
  187.         :(<0>2,:(r,default_prompt),0,y)
  188.     :(<0>2,(# ),0)
  189.     :(<0>2,(who),6)
  190.     :(<0>2,(user),6)
  191.     :(<0>2,(login),6)
  192.     :(<0>2,(logon),6)
  193.     :(<0>2,(name),6)
  194.     :(<0>2,(secret),7)
  195.     :(<0>2,(security),7)
  196.     :(<0>2,(key),7)
  197.     :(s,teach.prompts.msg0,(I am done with this teaching session.))
  198.     :(s,teach.prompts.msg1,(Abort this teaching session))
  199.     :(s,teach.prompts.msg2,(Ignore this prompt.))
  200.     :(s,teach.prompts.msg3,(Increase wait for next Prompt Dialog Box.))
  201.     :(s,teach.prompts.msg4,(Send a carriage return here.))
  202.     :(s,teach.prompts.msg5,(Send specific keys here.))
  203.     :(s,teach.prompts.msg6,(Use my username here.))
  204.     :(s,teach.prompts.msg7,(Use my password here.))
  205.     :(s,teach.prompts.msg8,(Connect to server now.))
  206.     :(s,teach.prompts.msg9,(Disconnect from server now.))
  207.     :(s,teach.prompts.nummsg,10)
  208.     :(d,<0>2)
  209. ))
  210.  
  211. :(o,,(
  212. <****************************************>
  213. <* Loadprompts Part Deuce-The workhorse *>
  214. <****************************************>
  215. ))
  216. :(mm,teach.loadprompts2,(
  217.     :(s,teach.prompts.num,:(aa,0:(r,teach.prompts.num),1))
  218.     :(s,teach.prompts.p:(r,teach.prompts.num),(<1>))
  219.     :(s,teach.prompts.d:(r,teach.prompts.num),(<2>))
  220.     :(ei,<3>,,,(
  221.         :(s,teach.prompts.e:(r,teach.prompts.num))
  222.     ))
  223. ))
  224. :(ri,teach.loadprompts)    :(o,,<* Build prompt db & discard loader *>)
  225.  
  226. :(o,,(
  227. <*********************************************>
  228. <* Parse out the important part out a prompt *>
  229. <* From the last CR                          *>
  230. <*********************************************>
  231. ))
  232. :(mm,teach.getprompt,(
  233.     :(s,<0>data,:(teach.iwt2)) <* Get data from strm *>
  234.     :(s,<0>data,:(r,<0>data):(bxo,0d0a))
  235.     :(tps,<0>data,0)
  236.     :(tra,<0>data,:(bxo,0d),:(bxo,0a))  <* convert CRs to LFs *>
  237.     :(tps,<0>data,0)
  238.     :(s,<0>retval) <* Start with no return value *>
  239.  
  240.     :(pcd,(
  241.         <* Find next LF delimitted prompt OR exit *>
  242.         :(s,<0>temp2,:(ts,<0>data,,:(bxo,0a),(:(px))))
  243.  
  244.         :(ei,:(r,<0>temp2),,,(
  245.             <* A prompt, save it if not NULL *>
  246.             :(s,<0>retval,:(r,<0>temp2))
  247.         ))
  248.     ),-1)
  249.  
  250.     <* Reverse Prompt *>
  251.     :(d,<0>revp)
  252.     :(tps,<0>retval,0)
  253.     :(pc,(
  254.         :(s,<0>revp,:(tn,<0>retval,1):(r,<0>revp))
  255.     ),:(tl,<0>retval))
  256.  
  257.     <* Reverse again this time cropping more *>
  258.     :(tps,<0>revp,0)
  259.     :(d,<0>retval)
  260.     :(d,<0>pflag)
  261.     :(d,<0>xflag)
  262.     :(pc,(
  263.         :(s,<0>tchar,:(tn,<0>revp,1))
  264.         :(pc,(
  265.             :(mhi,<0>pflag,,(
  266.                 :(agi,33,:(tcn,:(r,<0>tchar)),(
  267.                     :(px)
  268.                 ))
  269.             ))
  270.             :(s,<0>pflag)
  271.             :(agi,33,:(tcn,:(r,<0>tchar)),(
  272.                 :(s,<0>xflag)
  273.                 :(px)
  274.             ))
  275.             :(s,<0>retval,:(r,<0>tchar):(r,<0>retval))
  276.         ),1)
  277.         :(mhi,<0>xflag,(:(px)))
  278.     ),:(tl,<0>revp))
  279.  
  280.     <* Return cropped prompt *>
  281.     :(r,<0>retval)
  282.  
  283.     <* Clean up *>
  284.     :(d,<0>xflag,<0>revp,<0>pflag,<0>tchar,<0>retval,<0>temp2,<0>data)
  285. ))
  286.  
  287. :(o,,(
  288. <*****************************************************************>
  289. <* Get input until recognized prompt or 'n' second pause in stream *>
  290. <*****************************************************************>
  291. ))
  292. :(mm,teach.iwt2,(
  293.     :(s,<0>timer,:(xcm))    <* Reset timer *>
  294.     :(d,teach.sugres)    <* Reset suggested response *>
  295.     :(d,<0>retval)        <* Clear return value *>
  296.     :(d,<0>pfound)        <* Prompt found flag *>
  297.  
  298.     <* Loop until we find a prompt *>
  299.     :(pcd,( 
  300.  
  301.         :(s,<0>tmp,:(i2))    <* Get data from stream *>
  302.  
  303.         :(ei,:(r,<0>tmp),,(
  304.             <* Check For 'n' second Pause (Approx.) *>
  305.             :(agi,:(as,:(xcm),:(r,<0>timer)),:(r,timer),(
  306.                 :(px)
  307.             ))
  308.         ),(
  309.  
  310.             <* Concatanate Return Value, and Update Timer *>
  311.             :(s,<0>retval,:(r,<0>retval):(r,<0>tmp))
  312.             :(s,<0>timer,:(xcm))
  313.  
  314.                         <* throw away all but the last 250 bytes of retval*>
  315.                         :(s, size, :(tl, <0>retval))
  316.                         :(agi, :(r,size), 250, (
  317.                                 :(tps, <0>retval, :(r,size))
  318.                                 :(s, <0>tmp, :(tn, <0>retval,  -250, ) )
  319.                                 :(tps, <0>retval, 0)
  320.                                 :(s, <0>retval,:(r, <0>tmp) )
  321.                           )
  322.                         )
  323.                            
  324.             <* Remove excess from <0>retval *>
  325.             :(s,<0>rtemp,:(r,<0>retval) )
  326.             :(tra,<0>rtemp,:(tca,10),:(tca,13))
  327.             :(d,<0>cr)
  328.             :(agi,:(tl,<0>rtemp),0,(
  329.                 :(tps,<0>rtemp,:(as,:(tl,<0>rtemp),1))
  330.                 :(ei,:(tn,<0>rtemp,1),:(tca,13),(
  331.                     :(s,<0>cr)
  332.                 ))
  333.             ))
  334.             :(mhi,<0>cr,,(:(s,<0>rtemp,:(r,<0>rtemp):(tca,13))))
  335.             :(tps,<0>rtemp,0)
  336.             :(d,<0>lps)
  337.             :(pc,(
  338.                 :(s,<0>lp,:(ts,<0>rtemp,,:(tca,13),(:(px))))
  339.                 :(ei,:(r,<0>lp),,,(
  340.                     :(s,<0>lps,:(r,<0>lp))
  341.                 ))
  342.             ),-1)
  343.             :(s,<0>retval,:(r,<0>lps):(mh,<0>cr,:(tca,13)))
  344.             :(d,<0>rtemp,<0>lps,<0>cr,<0>lp)
  345.  
  346.             <* Look for certain prompt *>
  347.             :(pc,(
  348.                 <* Search for matching prompt *>
  349.                 <* Only if I am certain is prompt ext *>
  350.                 :(mhi,teach.prompts.e:(pn),(
  351.                     :(ttci,<0>retval,:(r,teach.
  352.                         prompts.p:(pn)),(
  353.  
  354.                         <* Set sug response *>
  355.                         :(s,teach.sugres,:(r,
  356.                             teach.prompts.d
  357.                             :(pn)))
  358.  
  359.                         :(px)
  360.                     ))
  361.                 ))
  362.             ),:(r,teach.prompts.num),1) <* Looking *>
  363.  
  364.             :(mhi,teach.sugres,(:(px))) <* Exit loop *>
  365.         ))
  366.     ),-1) <* Prompt found *>
  367.  
  368.     <* Search for suggested response *>
  369.     :(mhi,teach.sugres,,(
  370.         <* Look only if no certain prompt *>
  371.         :(pc,(
  372.             :(ttci,<0>retval,:(r,teach.prompts.p:(pn)),(
  373.                 <* Found suggestion *>
  374.                 :(s,teach.sugres,:(r,teach.prompts.d
  375.                     :(pn)))
  376.                 :(px)
  377.             ))
  378.         ),0:(r,teach.prompts.num),1)
  379.     ))
  380.  
  381.     <* Return prompt *>
  382.     :(r,<0>retval)
  383.  
  384.     <* Clean up *>
  385.     :(d,<0>timer,<0>tmp,<0>retval)
  386. ))
  387.  
  388. :(o,,(
  389. <**********************************>
  390. <* The heart and soul of genteach *>
  391. <**********************************>
  392. ))
  393. :(mm,teach.genteach,(
  394.     :(s,teach.script)    <* Start with a blank script *>
  395.     :(teach.start_scr)    <* General script filler *>
  396.         :(s,connect_pause,0)    <* initialize *>
  397.         :(s,loginprompt)        <* initialize variable name *>
  398.  
  399.         <* if already connected, ask user for the first wtnvt command *>
  400.         <* if not connected  - attempt a :(wtn_connect) first         *>
  401.         :(ei, :(r,is_connected), yes, 
  402.            (    
  403.            :(teach.prompt_first)
  404.            ),
  405.            (    
  406.            :(teach.genteach8)
  407.            :(s,connect_pause,1)
  408.            )
  409.         )  
  410.           
  411.     <* Loop until user says to stop/abort *>
  412.     :(pcd,(
  413.                 <* Get a prompt *>
  414.                 :(s,<0>temp,:(teach.getprompt))
  415.         :(ei,:(r,connect_pause),1,(
  416.                :(s,loginprompt,:(r,<0>temp))
  417.                :(teach.write_pause)
  418.                ),)
  419.  
  420.         <* Build a win_prompt command *>
  421.         :(s,<0>prompt,(:):(tca,40)(win_prompt,):(tca,40)
  422.             (How do you respond to "):(tca,41)
  423.             (:(r,<0>temp)):(tca,40)("?):(tca,41)(,,)
  424.             :(mh,teach.sugres,(:(r,teach.prompts.msg
  425.                 :(r,teach.sugres))))
  426.             :(pc,(
  427.                 (,):(tca,40)
  428.                 :(r,teach.prompts.msg:(pn)):(tca,41)
  429.             ),:(r,teach.prompts.nummsg),0)
  430.             :(tca,41))
  431.  
  432.         <* Ask the user what to do with the prompt *>
  433.         :(s,<0>temp2,:(ri,<0>prompt))
  434.  
  435.         <* Reset response number *>
  436.         :(s,<0>rnum,-1)
  437.  
  438.         <* See if this is a canned response *>
  439.         :(pcd,(
  440.             :(ei,:(r,<0>temp2),:(r,teach.prompts.
  441.                 msg:(pn)),(
  442.                 :(s,<0>rnum,:(pn))
  443.                 :(px)
  444.             ))
  445.         ),:(r,teach.prompts.nummsg),0) <* Canned? *>
  446.  
  447.             <* Check if a ctl respe (done,abort,ignore)*>
  448.         :(ei,:(e,:(r,<0>rnum),0,y):(e,:(r,<0>rnum),1,y)
  449.                         :(e,:(r,<0>rnum),2,y),,(
  450.             <* Bld scrpt, chck agst prmpt *>
  451.                          :(ei, :(r,connect_pause),1,,(
  452.             :(teach.write_scr,((:):(tca,40)(o,,<)
  453.                 (* Waiting For Prompt "):(r,<0>temp)
  454.                 (" *)(>):(tca,41)))
  455.             :(teach.write_scr,(:(teach.open)(s,teach.)
  456.                 (response,):(teach.open)(teach.iwt2,)
  457.                 :(tca,40):(r,<0>temp):(tca,41)
  458.                 (,:(r,timer)):(teach.close):(teach.close)))
  459.             :(teach.write_scr,(:(teach.open)
  460.                 (ttci,teach.response,):(tca,40)
  461.                 :(r,<0>temp):(tca,41)(,):(tca,40)))
  462.             :(teach.write_scr,(:(tca,9)(:):(tca,40)(o,,<)
  463.                 (* Found prompt *)(>):(tca,41)))
  464.             :(teach.write_scr,(:(tca,9)))
  465.         ))))
  466.             
  467.         :(ei,:(r,<0>rnum),-1,(
  468.             <* Not canned, original work! *>
  469.             <* Protect parens and gt-lt symbols *>
  470.             :(tra,<0>temp2,:(tca,40),:(tca,41)(:):(tca,40)
  471.                 (tca,40):(tca,41):(tca,40))
  472.             :(tra,<0>temp2,:(tca,41),:(tca,41)(:):(tca,40)
  473.                 (tca,41):(tca,41):(tca,40))
  474.             :(tra,<0>temp2,(<),:(tca,41)(:):(tca,40)(<)
  475.                 :(tca,41):(tca,40))
  476.             :(tra,<0>temp2,(>),:(tca,41)(:)
  477.                 :(tca,40)(>):(tca,41):(tca,40))
  478.             :(s,<0>temp2,:(tca,40):(r,<0>temp2):(tca,41))
  479.  
  480.             <* Write to script *>
  481.             :(teach.write_scr,(:(tca,9):(teach.open)
  482.                 (wtn_sendkeys,):(r,<0>temp2)
  483.                 :(tca,40)(<Enter>):(tca,41)
  484.                 :(teach.close)))
  485.  
  486.             <* Send to stream *>
  487.             :(wtn_sendkeys,:(ri,<0>temp2)(<Enter>))
  488.         
  489.         ),(
  490.             <* Boring canned response *>
  491.             :(ri,<0>:(r,<0>rnum),<1p>)
  492.         ))
  493.  
  494.                 :(ei,:(r,connect_pause),1,(:(s,connect_pause,0) ),
  495.                      (:(ei,:(e,:(r,<0>rnum),0,y):(e,:(r,<0>rnum),1,y)
  496.             :(e,:(r,<0>rnum),2,y),,(
  497.             :(teach.write_scr,(:(tca,9)))
  498.             :(teach.write_scr,(:(tca,41)(,):(tca,40)))
  499.             :(teach.write_scr,(:(tca,9)(:):(tca,40)(o,,<)
  500.                 (* Unknown prompt, get help )
  501.                 (from user *)(>):(tca,41)))
  502.             :(teach.write_scr,(:(tca,9)))
  503.             :(teach.write_scr,(:(tca,9):(teach.open)
  504.                 (teach.help,teach.response)
  505.                 :(teach.close)))
  506.             :(teach.write_scr,(:(tca,41):(tca,41)))
  507.             :(teach.write_scr)
  508.             ))))
  509.     ),-1) <* Loop til user says uncle *>
  510.  
  511.     <* Clean up *>
  512.     :(d,<0>temp,<0>temp2,<0>rnum,teach.sug)
  513.  
  514.     :(g) <* End the script *>
  515. ))
  516.  
  517. :(mm,teach.genteach0,(
  518.     <* User says Done *>
  519.  
  520.     <* Normally I would write the script here, but I don't *>
  521.     <* know the filename                                   *>
  522.  
  523.     :(fc5)
  524.     :(fg5,<1p>,(
  525.         :(win_message,(Fatal Error; cannot create file "<1p>"!))
  526.         :(g)
  527.     ))
  528.     :(fw5,:(r,teach.script))
  529.  
  530.     <* Always end the script when done *>
  531.     :(fw5,:(bx0,0d0a))
  532.     :(fw5,(:):(tca,40)(o,,):(tca,40))
  533.     :(fw5,(<)(*************************)(>):(bxo,0d0a))
  534.     :(fw5,(<)(* Terminate this script *)(>):(bxo,0d0a))
  535.     :(fw5,(<)(*************************)(>):(bxo,0d0a))
  536.     :(fw5,:(tca,41):(tca,41):(bxo,0d0a))
  537.     :(fw5,(:):(tca,40)(g):(tca,41):(bxo,0d0a))
  538.  
  539.     :(fc5)
  540.     :(d,teach.script)
  541.     :(px)
  542. ))
  543. :(mm,teach.genteach1,(
  544.     <* User says Abort, Do not write any scripts *>
  545.  
  546.     :(d,teach.script)
  547.     :(px)
  548. ))
  549.  
  550. :(o,,(
  551. <***************************************************>
  552. <* Return user's username, ask for it if necessary *>
  553. <***************************************************>
  554. ))
  555. :(mm,teach.username,(
  556.     :(ei,:(win_username),,(    
  557.         :(win_username,:(win_prompt,(Enter your username:)))
  558.     ))
  559.     :(win_username)
  560. ))
  561.  
  562. :(o,,(
  563. <***************************************************>
  564. <* Return user's password, ask for it if necessary *>
  565. <***************************************************>
  566. ))
  567. :(mm,teach.passcode,(
  568.     :(ei,:(win_passcode),,(
  569.         :(win_passcode,:(win_prompt,(Enter your password:),*))
  570.     ))
  571.     :(win_passcode)
  572. ))
  573.  
  574. :(mm,teach.genteach2,(
  575.     <* Ignore this prompt *>
  576. ))
  577.  
  578. :(mm,teach.genteach3,(
  579.     <* Increase timer *>
  580.        :(s,timer,:(aa,:(r,timer),5000))
  581. ))
  582.  
  583. :(mm,teach.genteach4,(
  584.     <* Send a carriage return *>
  585.     
  586.     :(teach_write_scr)
  587.     :(teach.write_scr,(:(tca,9)(:):(tca,40)(o,,<)(* Send a CR *)(>)
  588.         :(tca,41)))
  589.     :(teach.write_scr,(:(tca,9):(teach.open)(wtn_sendkeys,)
  590.         :(tca,40)(<Enter>):(tca,41):(teach.close)))
  591.     :(wtn_sendkeys,(<Enter>))
  592. ))
  593.  
  594. :(mm,teach.genteach5,(
  595.     <**********************>
  596.     <* Send specific keys *>
  597.     <**********************>
  598.  
  599.     :(d,<0>sendkeys)
  600.     :(d,<0>exitflag)
  601.     :(s,<0>numk,0)
  602.     :(s,<0>kpos.)
  603.  
  604.     :(pcd,(
  605.         <* Prepare to build the prompt *>
  606.         :(s,<0>px,:(r,<0>sendkeys))
  607.  
  608.         <* Protect the innocent TRAC delimiters *>
  609.         :(tra,<0>px,:(tca,40),:(tca,41)(:(tca,40)):(tca,40))
  610.         :(tra,<0>px,:(tca,41),:(tca,41)(:(tca,41)):(tca,40))
  611.         :(tra,<0>px,:(tca,60)(*),:(tca,41)(:(tca,60)):(tca,40)
  612.             (*))
  613.         :(tra,<0>px,(*):(tca,62),(*):(tca,41)(:(tca,62))
  614.             :(tca,40))
  615.         :(tra,<0>px,:(tca,44),:(tca,41)(:(tca,44)):(tca,40))
  616.         :(s,<0>px,:(tca,40):(r,<0>px):(tca,41))
  617.  
  618.         <* Really build a prompt *>
  619.         :(s,<0>prompt,:(teach.open)(win_prompt,):(tca,40)
  620.         (Return: "):(ri,<0>px)("):(tca,41)(:(bxo,0a0d)):(tca,40)
  621.         (Send which key:):(tca,41)(,,)((I am done.),)
  622.         ((Delete last key.),(I am done.),)
  623.         ((Abort without sending keys.))
  624.             :(pc,(
  625.                 (,):(tca,40):(r,teach.keys.k:(pn)):(tca,41)
  626.             ),:(r,teach.keys.num),1)
  627.         :(tca,41))
  628.  
  629.  
  630.         :(d,<0>px)    <* Throw away temp *>
  631.  
  632.         :(s,<0>pres,:(ri,<0>prompt))    <* Prompt the user *>
  633.  
  634.         :(pc,(
  635.             :(ei,:(r,<0>pres),(Delete last key.),(
  636.                 <* Delete Last key *>
  637.                 :(agi,:(r,<0>numk),0,(
  638.                     :(tps,<0>sendkeys,:(r,<0>kpos.
  639.                         :(r,<0>numk)))
  640.                     :(s,<0>sendkeys,:(tpb,<0>sendkeys))
  641.                     :(d,<0>kpos.:(r,<0>numk))
  642.                     :(s,<0>numk,:(as,:(r,<0>numk),1))
  643.                 ))
  644.                 :(px)
  645.             ))
  646.             :(ei,:(r,<0>pres),(I am done.),(
  647.                 <* Finish up *>
  648.                 :(s,<0>exitflag)
  649.                 :(px)
  650.             ))
  651.             :(ei,:(r,<0>pres),(Abort without sending keys.),(
  652.                 <* Abort *>
  653.                 :(d,<0>sendkeys)
  654.                 :(s,<0>exitflag)
  655.                 :(px)
  656.             ))
  657.  
  658.             <* Store Last Position *>
  659.             :(s,<0>numk,:(aa,0:(r,<0>numk),1))
  660.             :(s,<0>kpos.:(r,<0>numk),:(tl,<0>sendkeys))
  661.  
  662.             <* Get String to send *>
  663.             :(s,<0>keyv,:(r,<0>pres))    <* Default case *>
  664.             :(pcd,(
  665.                 :(ei,:(r,<0>pres),:(r,teach.keys.k:(pn)),(
  666.                     :(s,<0>keyv,:(r,teach.keys.v:(pn)))
  667.                     :(px)
  668.                 ))
  669.             ),:(r,teach.keys.num),1)
  670.  
  671.             :(0,:(r,<0>keyv))
  672.  
  673.             <* Add key to list *>
  674.             :(s,<0>sendkeys,:(r,<0>sendkeys):(r,<0>keyv))
  675.         ))
  676.         :(mhi,<0>exitflag,(:(px)))
  677.     ),-1)
  678.  
  679.     :(agi,:(tl,<0>sendkeys),0,(
  680.         <* Protect the innocent TRAC delimiters *>
  681.         :(tra,<0>sendkeys,:(tca,40),:(tca,41)(:(tca,40)):(tca,40))
  682.         :(tra,<0>sendkeys,:(tca,41),:(tca,41)(:(tca,41)):(tca,40))
  683.         :(tra,<0>sendkeys,:(tca,60)(*),:(tca,41)(:(tca,60)):(tca,40)
  684.             (*))
  685.         :(tra,<0>sendkeys,(*):(tca,62),(*):(tca,41)(:(tca,62))
  686.             :(tca,40))
  687.         :(tra,<0>sendkeys,:(tca,44),:(tca,41)(:(tca,44)):(tca,40))
  688.         :(s,<0>sendkeys,:(tca,40):(r,<0>sendkeys):(tca,41))
  689.  
  690.         :(teach_write_scr)
  691.         :(teach.write_scr,(:(tca,9)(:):(tca,40)(o,,<)
  692.             (* Send specific keys *)(>):(tca,41)))
  693.         :(teach.write_scr,(:(tca,9):(teach.open)(wtn_sendkeys,)
  694.             :(r,<0>sendkeys):(teach.close)))
  695.         :(wtn_sendkeys,:(ri,<0>sendkeys))
  696.     ))
  697.  
  698.     :(d,<0>prompt,<0>keynum,<0>keyval,<0>pres,<0>keyv,<0>sendkeys,
  699.         <0>exitflag,<0>numk,<0>kpos.)
  700. ))
  701. :(mm,teach.genteach6,(
  702.     <* Username *>
  703.  
  704.     <* Get username from WTN *>
  705.  
  706.     :(teach_write_scr)
  707.     :(teach.write_scr,(:(tca,9)(:):(tca,40)(o,,<)(* Send username *)(>)
  708.         :(tca,41)))
  709.     :(teach.write_scr,(:(tca,9):(teach.open)(wtn_sendkeys,)
  710.         :(teach.open)(teach.username):(teach.close)
  711.         :(tca,40)(<Enter>):(tca,41):(teach.close)))
  712.     :(wtn_sendkeys,:(teach.username)(<Enter>))
  713. ))
  714.  
  715. :(mm,teach.genteach7,(
  716.     <* Password *>
  717.  
  718.     <* Get password from WTN *>
  719.  
  720.     :(teach_write_scr)
  721.     :(teach.write_scr,(:(tca,9)(:):(tca,40)(o,,<)(* Send password *)(>)
  722.         :(tca,41)))
  723.     :(teach.write_scr,(:(tca,9):(teach.open)(wtn_sendkeys,)
  724.         :(teach.open)(teach.passcode):(teach.close):(tca,40)
  725.         (<Enter>):(tca,41):(teach.close)))
  726.     :(wtn_sendkeys,:(teach.passcode)(<Enter>))
  727. ))
  728.  
  729. :(mm,teach.genteach8,(
  730.     <* Connect *>
  731.  
  732.     :(wtn_connect)
  733.     :(teach.write_scr,(:(tca,9)(:):(tca,40)(o,,<)(* Connect to server *)
  734.         (>):(tca,41)))
  735.     :(teach.write_scr,(:(tca,9):(teach.open)(wtn_connect)
  736.         :(teach.close)))
  737. ))
  738.  
  739. :(mm,teach.genteach9,(
  740.     <* Disconnect *>
  741.  
  742.     :(teach.write_scr,(:(tca,9)(:):(tca,40)(o,,<)
  743.         (* Disconnect from server *)(>):(tca,41)))
  744.     :(teach.write_scr,(:(tca,9):(teach.open)(wtn_disconnect)
  745.         :(teach.close)))
  746.  
  747.     :(wtn_disconnect)
  748. ))
  749.  
  750. :(mm,teach.start_scr,(
  751.     <* Script file header *>
  752.     :(<0>w,((:):(tca,40)(o,,<)(*)
  753. (*********************************************************************)(>)
  754.     :(tca,41)))
  755.     :(<0>w,((:):(tca,40)(o,,<)(*)
  756. ( This script was automatically generated by TNVT teach mode.         *)(>)
  757.     :(tca,41)))
  758.     :(<0>w,((:):(tca,40)(o,,<)(*)
  759. ( Created: ):(xcf)(                                *)(>)
  760.     :(tca,41)))
  761.     :(<0>w,((:):(tca,40)(o,,<)(*)
  762. (*********************************************************************)(>)
  763.     :(tca,41)))
  764.     :(<0>w)
  765.  
  766.     <* Read common TRAC code from GENTEACH.WTN *>
  767.     :(fc5)
  768.     :(fo5,:(r,##teach_wtn),(
  769.         :(win_message,(Fatal Error; cannot open ):(r,##teach_wtn)(!))
  770.         :(g)
  771.     ))
  772.     :(pcd,(
  773.         :(s,<0>temp,:(fr5,:(bxo,0a),,(:(px))))
  774.         <*:(tra,<0>temp,:(bx0,0d),)*>
  775.         <*:(tra,<0>temp,:(bxo,0a),)*>
  776.  
  777.         :(teach.write_scr,(:(r,<0>temp)))
  778.     ),-1)
  779.     :(fc5)
  780.     :(teach.write_scr)
  781. ))
  782. :(o,,(
  783. <****************************************************************************>
  784. <* If teach mode began after login, ask user what to send initially?        *>
  785. <****************************************************************************>
  786. ))
  787. :(mm,teach.prompt_first,(
  788.         <* ask user to define the user prompt to look for on the host *>
  789.  
  790.         :(d,hostcmd)
  791.         :(s,hostcmd,
  792.         :(win_prompt,(Please enter your initial TNVT command:)) )
  793.  
  794.     <* Write to script *>
  795.     :(teach.write_scr,(:(tca,9):(teach.open)
  796.         (wtn_sendkeys,):(tca,40):(r,hostcmd)<Enter>:(tca,41):(teach.close)))
  797.  
  798.     <* Send to stream *>
  799.     :(wtn_sendkeys,:(r,hostcmd)(<Enter>))
  800.  
  801. ))
  802.  
  803. :(o,,(
  804. <**************************************>
  805. <* Teach write script shortcut macros *>
  806. <**************************************>
  807. ))
  808. :(mm,teach.open,((:):(tca,40)))
  809. :(mm,teach.close,(:(tca,41)))
  810. :(mm,teach.start_scrw,(
  811.     :(teach.write_scr,(<1>))
  812. ))
  813. :(mm,teach.write_scr,(
  814.     :(s,teach.script,:(r,teach.script)<1>:(bxo,0d0a))
  815. ))
  816.  
  817. :(mm,teach.write_pause,(
  818.         :(s,pcd_str,(wtn_receive,):(r,timer)(,):(r,loginprompt))
  819.         :(teach_write_scr)
  820.     :(teach.write_scr,(:(tca,9)(:):(tca,40)(o,,<)(* Pause till login input *)(>)
  821.         :(tca,41) ) )
  822.     :(teach.write_scr,(:(tca,9):(teach.open)
  823.                 :(r,pcd_str):(teach.close)))
  824. ))
  825.                 
  826. :(o,,(
  827. <**************************************************************>
  828. <* Le Bootstrap, called by WTN after reading in script file   *>
  829. <* <1> should contain the name of the script file to generate *>
  830. <**************************************************************>
  831. ))
  832. :(mm,##,(
  833.         <* send initial welcome message and information about teach mode*>
  834.  
  835.     <* Get temporary output script filename                       *>
  836.     :(s,<0>filename,(<2p>))
  837.         :(s,<0>teach_wtn,(<1p>))
  838.  
  839.         :(s,is_connected,(<3p>))  <* are we already logged in? *>
  840.  
  841.     <* Start learn mode *>
  842.     :(ri,teach.genteach,:(r,<0>filename))
  843.  
  844.     <* Clean up, I should never get here but it looks good *>
  845.     :(d,<0>filename)
  846. ))
  847.  
  848.