home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / pmtl11a.zip / tagline.cmd < prev    next >
OS/2 REXX Batch file  |  1996-10-20  |  5KB  |  158 lines

  1. /*  Tagline Exit Script for PMMail - Copyright 1996, Stephen Berg and IceBerg  */
  2. /*                                   Software Productions.                     */
  3.  
  4. Parse Arg targetfile
  5. '@echo off'
  6.  
  7. Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  8. Call SysLoadFuncs
  9.  
  10. /*  Now for the TagLine stuff                                    */
  11.  
  12. /*  First we load up the VRexx utilities so we can create and manipulate the   */
  13. /*  The pretty windows!!  =:-)                                                 */
  14. call RxFuncAdd 'Vinit', 'VREXX', 'VINIT'
  15. initcode = VInit()
  16.     if initcode = 'ERROR' then SIGNAL CLEANUP
  17.     signal on failure name CLEANUP
  18.     signal on halt name CLEANUP
  19.     signal on syntax name CLEANUP
  20.  
  21. Call Start
  22.  
  23. /*  Now we create a small dialog to let the user pick how he/she wants the     */
  24. /*  tagline for the current message to be chosen.                              */
  25. Start:
  26.  
  27. pick.0 = 5
  28. pick.1 = 'Let PMTagLine randomly pick a TagLine.'
  29. pick.2 = 'Pick one from the file specifically.'
  30. pick.3 = 'Input your own TagLine manually.'
  31. pick.4 = 'Search for text in a tagline, then pick'
  32. pick.5 = 'Bypass the TagLine insertion.'
  33. Call VRadioBox 'PMTagLine V 1.10', pick, 1
  34. choice = pick.vstring
  35.  
  36. /*  Take action according to the user's choice.                                */
  37. SELECT
  38. WHEN choice = pick.1 THEN
  39.     Call PickRandom
  40. WHEN choice = pick.2 THEN
  41.     Call PickOne
  42. WHEN choice = pick.3 THEN
  43.     CALL Insert
  44. WHEN choice = pick.4 THEN
  45.     CALL SearchPick
  46. WHEN choice = pick.5 THEN
  47.     CALL QuitIt
  48. OTHERWISE 
  49.     Call QuitIt
  50. end
  51.  
  52. /*  Make sure that the message is closed before we exit.                       */
  53.     rc = LineOut(targetfile)
  54. Return
  55.  
  56. /*  Kill any remaining VREXX stuff.                                            */
  57. CLEANUP:
  58.     Say 'PMTagLine interrupted!!'
  59.     Call QuitIt
  60. return
  61.  
  62. /*  For randomly picking taglines                                              */
  63. PickRandom:
  64.     Call GetTagArray
  65.     pick = RANDOM(1, tagline.0)
  66.     tag = tagline.pick
  67.     rc = LineOut(targetfile, 'PMTagLine v1.1 - Copyright, 1996, Stephen Berg')
  68.     rc = LineOut(targetfile, '...' tag)
  69.     rc = LineOut(targetfile)
  70.     Call QuitIt
  71. return
  72.  
  73. /*  To let the user specifically pick one tagline from the taglines.txt       */
  74. /*  file                                                                      */
  75. PickOne:
  76.     Call GetTagArray
  77.     Call VListBox 'Pick a tagline', tagline, 60, 10, 1
  78.     tag = tagline.vstring
  79.     rc = LineOut(targetfile, 'PMTagLine v1.1 - Copyright, 1996, Stephen Berg')
  80.     rc = LineOut(targetfile, '...' tag)
  81.     rc = LineOut(targetfile)
  82.     Call QuitIt
  83. return
  84.  
  85. /*  To let the user insert their own tagline                                   */
  86. Insert:
  87.     msg.0 = 3
  88.     msg.1 = 'Please input your own tagline'
  89.     msg.2 = 'in the window below.'
  90.     msg.3 = ''
  91.     msg.vstring = 'Insert witty remark here'
  92.     Call VInputBox 'PMTagLine V 0.10', msg, 60, 1
  93.     tag = msg.vstring
  94.     rc = LineOut(targetfile, 'PMTagLine v1.1 - Copyright, 1996, Stephen Berg')
  95.     rc = LineOut(targetfile, '...' tag)
  96.     rc = LineOut(targetfile)
  97.     Call QuitIt
  98. return
  99.  
  100. /*  Search for a particular string, load it into an array to allow the         */
  101. /*  User to pick from them.                                                    */
  102. SearchPick:
  103.     msg.0 = 3
  104.     msg.1 = 'Input the string to search for:'
  105.     msg.2 = 'Click OK to continue'
  106.     msg.3 = ''
  107.     CALL VInputBox 'PM TagLine V1.1', msg, 60, 1
  108.     text = msg.vstring
  109.     CALL LoadUtils
  110.     rc = SysFileSearch(text, 'tagline.txt', tagline)
  111.     Call VListBox 'Pick a tagline', tagline, 60, 10, 1
  112.     tag = tagline.vstring
  113.     if tag = "TAGLINE.VSTRING" then do
  114.         msg.0 = 3
  115.         msg.1 = "The string you searched for was not found in the tagline"
  116.         msg.2 = "file.  Please try again"
  117.         msg.3 = ""
  118.         Call VMsgBox "Error on Search", msg, 1
  119.         Call Start
  120.     end
  121.     else do
  122.         rc = LineOut(targetfile, 'PMTagLine v1.1 - Copyright, 1996, Stephen Berg')
  123.         rc = LineOut(targetfile, '...' tag)
  124.         rc = LineOut(targetfile)
  125.     end
  126.     Call QuitIt
  127. exit
  128.  
  129.         
  130. /*  Load the tagline file into an array for either picking or random choice.   */
  131. GetTagArray:
  132.     cnt = 0
  133.     do While Lines('tagline.txt') > 0
  134.         cnt = cnt + 1
  135.         tagline.0 = cnt
  136.         tagline.cnt = LineIn('tagline.txt')
  137.     end
  138. return
  139.  
  140. /* Inform the user that the search found no taglines and then restart the   */
  141. /* Search routine                                                           */
  142.  
  143.  
  144. /* Load the REXXUtil functions                                                 */
  145. LoadUtils:
  146. CALL RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  147. CALL SysLoadFuncs
  148. Return
  149.  
  150. /* Close up and shut down   */
  151. /*  Or for no tagline functions to the current message.                           */
  152.  
  153. QuitIt:
  154.     Call VExit
  155. exit
  156.  
  157.  
  158.