home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 3 / Meeting_Pearls_III.iso / Pearls / comm / Fido / Spot / Rexx / FileHatch.spot < prev    next >
Text File  |  1994-05-30  |  11KB  |  332 lines

  1. /***************************************************************************/
  2. /*                                                                         */
  3. /* FileHatch.spot       ©1993/94 Stefan Zeiger       2:244/6302.15@fidonet */
  4. /*                                                                         */
  5. /* $VER: FileHatch.spot 1.6 (30.5.94)                                      */
  6. /*                                                                         */
  7. /* [Based roughly on SkyHatch.spot by Stu Churchill]                       */
  8. /*                                                                         */
  9. /* This script will hatch a file using FHatch or SkyTick and post an       */
  10. /* announcement in the appropriate area.                                   */
  11. /*                                                                         */
  12. /* Yes! Hatching a file is really *that* easy! ;)                          */
  13. /*                                                                         */
  14. /***************************************************************************/
  15. /*                                                                         */
  16. /* Instructions: - Install FTick/FHatch or SkyTick, if you haven't done    */
  17. /*                 this already.                                           */
  18. /*                                                                         */
  19. /*               - Modify the settings below. All variables' meanings      */
  20. /*                 should be quite obvious                                 */
  21. /*                                                                         */
  22. /*               - Add FileHatch.spot in Spot's ARexx menu or start it     */
  23. /*                 directly via rx.                                        */
  24. /*                                                                         */
  25. /*               - Have fun with this script! ;)                           */
  26. /*                                                                         */
  27. /***************************************************************************/
  28. /*                                                                         */
  29. /* 20.09.1993  1.0    First release                                        */
  30. /* 21.09.1993  1.1    Largely enhanced                                     */
  31. /* 24.09.1993  1.2    Hatched file is now copied with 'clone'              */
  32. /*             1.3    FileHatch can now use both FHatch and SkyTick        */
  33. /*             1.4    Generic list requester procedures added              */
  34. /* 25.09.1993  1.5    Bugs fixed                                           */
  35. /* 30.05.1994  1.6    Long file description creation added                 */
  36. /*                                                                         */
  37. /***************************************************************************/
  38.  
  39.  
  40. fhatch_path   = 'mail:bin/FHatch'
  41. ftick_cfg     = 'mail:tick.cfg'
  42.  
  43. skytick_path  = 'mail:skytick/SkyTick'
  44. skytick_cfg   = 'mail:sky'                /*  -> mail:skyTICK.CFG */
  45.  
  46. used_program  = 'fhatch'                /* [fhatch|skytick|none] */
  47.  
  48. from_name     = 'Stefan Zeiger'
  49. host_name     = '2:244/6302.15'
  50. to_name       = 'All'
  51. subj_line     = 'File Arrival Announcement'
  52. origin        = 'FileHatch.spot, (c) 1993/94 by Stefan Zeiger'
  53. ldesc_quote   = '   '
  54. use_origin    = 'yes'
  55.  
  56. temp_dir      = 'T:'                    /* Must end in ':' or '/' */
  57. spot_path     = 'sys:comm/spot/Spot'
  58. editor_path   = 's:keepced'
  59.  
  60. file_path     = 'outgoing:'
  61. keep_original = 'yes'
  62.  
  63. call newlist()
  64. call addlist('SPOT_BETA')
  65. call addlist('UPLOAD.ALLG')
  66. call addlist('UPLOAD.AMIGA')
  67. call addlist('UPLOAD.DTP')
  68. call addlist('UPLOAD.MOD')
  69. call addlist('UPLOAD.PIX')
  70. call addlist('UPLOAD.RAY')
  71.  
  72.  
  73. /***************************************************************************/
  74. /* Set up system                                                           */
  75. /***************************************************************************/
  76.  
  77. options results
  78.  
  79. CR = '0d'x
  80.  
  81. temp_file = temp_dir'FileHatch.spot.TMP'
  82. desc_file = temp_dir'FileHatch.spot.DESC'
  83.  
  84. if ~show(l, 'rexxsupport.library') then do
  85.   if ~addlib('rexxsupport.library', 0, -30) then do
  86.     say 'Please install the rexxsupport.library in your libs: directory'
  87.   end
  88. end
  89.  
  90. if ~show('ports','SPOT') then do
  91.   address command spot_path
  92.   'WaitForPort SPOT'
  93.   if rc = 5 then do
  94.     call cleanup()
  95.   end
  96.   quit = 'yes'
  97. end
  98.  
  99. 'isiconified'
  100. if rc = 0 then do
  101.   icon = 'yes'
  102.   'uniconify'
  103. end
  104.  
  105.  
  106. /***************************************************************************/
  107. /* Ask for the file, area and description                                  */
  108. /***************************************************************************/
  109.  
  110. address spot
  111.  
  112. 'requestfile title "Hatch file..." path 'file_path
  113. if rc>0 then call cleanup()
  114. hatchfile=result
  115.  
  116. filearea_name=picklist("Hatch in...")
  117. if filearea_name='CANCELLED' then call cleanup()
  118. if filearea_name='' then call cleanup()
  119.  
  120. 'requestarea title "Announce in..."'
  121. if rc>0 then call cleanup()
  122. echo_name=result
  123.  
  124. address command
  125. call statef(hatchfile)
  126. parse var result dummy filelength dummy dummy dummy dummy dummy description
  127. description=substr(description,2)
  128.  
  129. address spot
  130.  
  131. 'requeststring title "Description..." prompt "Please enter the description" center default "'description'"'
  132. if rc>0 then call cleanup()
  133. description=result
  134.  
  135. 'requestresponse title "FileHatch request" prompt "Do you want to enter a long description?'||CR||CR||'(If you enter a description, you should'||CR||'not use more than 60 characters per line)" gadgets "_Yes|_No" center'
  136. if rc>0 then do
  137.   use_desc='yes'
  138.   address command
  139.   editor_path desc_file
  140. end
  141. else use_desc='no'
  142.  
  143.  
  144. /***************************************************************************/
  145. /* Create the announcement                                                 */
  146. /***************************************************************************/
  147.  
  148. address command
  149.  
  150. call delete(temp_file)
  151. hatchdate=date()', 'time()
  152. separator=lastpos('/',hatchfile)
  153. if separator=0 then separator=lastpos(':',hatchfile)
  154. if separator=0 then hatchfile_base=hatchfile
  155. else hatchfile_base=substr(hatchfile,separator+1)
  156.  
  157. call open('TEMP',temp_file,'W')
  158. call writeln('TEMP','')
  159. call writeln('TEMP','')
  160. call writeln('TEMP',' The following file has just been hatched at 'host_name' :')
  161. call writeln('TEMP','')
  162. call writeln('TEMP','')
  163. call writeln('TEMP',' File name   : 'hatchfile_base)
  164. call writeln('TEMP',' Length      : 'filelength)
  165. call writeln('TEMP',' Description : 'description)
  166. call writeln('TEMP',' File area   : 'filearea_name)
  167. call writeln('TEMP',' Origin      : 'host_name)
  168. call writeln('TEMP',' Date, Time  : 'hatchdate)
  169. if use_desc='yes' then do
  170.   call writeln('TEMP','')
  171.   call writeln('TEMP',' Long descr. :')
  172.   call writeln('TEMP','')
  173.   call open('DESC',desc_file,'R')
  174.     descline=readln('DESC')
  175.     do until EOF('DESC')
  176.       call writech('TEMP',ldesc_quote)
  177.       call writeln('TEMP',descline)
  178.       descline=readln('DESC')
  179.     end
  180.   call close('DESC')
  181. end
  182. call writeln('TEMP','')
  183. call writeln('TEMP','')
  184. call writeln('TEMP',' Information supplied by FileHatch.spot 1.6  (c) 1993/94 by Stefan Zeiger')
  185. call writeln('TEMP','')
  186. call close('TEMP')
  187.  
  188.  
  189. /***************************************************************************/
  190. /* Hatch the file                                                          */
  191. /***************************************************************************/
  192.  
  193. select
  194.   when used_program='skytick' then call hatch_with_skytick()
  195.   when used_program='fhatch' then call hatch_with_fhatch()
  196.   otherwise nop
  197. end
  198.  
  199.  
  200. /***************************************************************************/
  201. /* Write the file announcement message into the specified area             */
  202. /***************************************************************************/
  203.  
  204. address spot
  205. 'lockgui'
  206. 'arealist'
  207. 'gotoarea NAME 'echo_name
  208. if rc ~= 0 then do
  209.   'requestnotify PROMPT "Could not find area'||CR||echo_name'"'
  210.   call cleanup()
  211. end
  212. 'messagelist'
  213. if use_origin='yes' then 'write TO "'to_name'" FROM "'from_name'" SUBJECT "'subj_line'" FILE 'temp_file' ORIGIN "'origin'" NOEDIT NOGUI NOSIG'
  214. else 'write TO "'to_name'" FROM "'from_name'" SUBJECT "'subj_line'" FILE 'temp_file' NOEDIT NOGUI NOSIG'
  215. 'arealist'
  216. 'unlockgui'
  217.  
  218.  
  219. /***************************************************************************/
  220. /* Exit gracefully                                                         */
  221. /***************************************************************************/
  222.  
  223. if icon = 'yes' then do
  224.   'iconify NOREQ'
  225. end
  226.  
  227. if quit = 'yes' then do
  228.   'quitspot NOREQ'
  229. end
  230.  
  231. call delete(temp_file)
  232. call delete(desc_file)
  233. call deletelist()
  234.  
  235. call cleanup()
  236.  
  237.  
  238. /***************************************************************************/
  239. /* Hatch the file using FHatch                                             */
  240. /***************************************************************************/
  241.  
  242. hatch_with_fhatch:
  243.  
  244.   address command
  245.  
  246.   if keep_original='yes' then 'copy 'hatchfile' to 'temp_dir||hatchfile_base' clone'
  247.  
  248.   fhatch_path' "'ftick_cfg'" "'hatchfile'" 'filearea_name' "'description'" >CON:40/40/590/100/FHatch/AUTO/CLOSE/DONOTWAIT/SCREENSPOT'
  249.  
  250.   if keep_original='yes' then do
  251.     'copy 'temp_dir||hatchfile_base' to 'hatchfile' clone'
  252.     call delete(temp_dir||hatchfile_base)
  253.   end
  254.  
  255.   if rc ~= 0 then do
  256.     address spot
  257.     'requestnotify PROMPT "Could not hatch file'||CR||hatchfile'"'
  258.     call cleanup()
  259.   end
  260.  
  261. return
  262.  
  263.  
  264. /***************************************************************************/
  265. /* Hatch the file using SkyTick                                            */
  266. /***************************************************************************/
  267.  
  268. hatch_with_skytick:
  269.  
  270.   address command
  271.  
  272.   if keep_original='yes' then skytick_path' "-C'skytick_cfg'" "-F'hatchfile_base'" "-R'hatchfile_base'" "-P'file_path'" "-A'filearea_name'" "-D'description'" -H HATCH >CON:40/40/590/100/SkyTick/AUTO/CLOSE/DONOTWAIT/SCREENSPOT'
  273.   else skytick_path' "-C'skytick_cfg'" "-F'hatchfile'" "-R'hatchfile'" "-A'filearea_name'" "-D'description'" -H -Q HATCH >CON:40/40/590/100/SkyTick/AUTO/CLOSE/DONOTWAIT/SCREENSPOT'
  274.  
  275.   if rc ~= 0 then do
  276.     address spot
  277.     'requestnotify PROMPT "Could not hatch file'||CR||hatchfile'"'
  278.     call cleanup()
  279.   end
  280.  
  281. return
  282.  
  283.  
  284. /***************************************************************************/
  285. /* A generic list requester                                                */
  286. /***************************************************************************/
  287.  
  288. newlist: procedure
  289.   address command
  290.   'makedir t:list-requester >NIL:'
  291. return
  292.  
  293.  
  294. deletelist: procedure
  295.   address command
  296.   'delete t:list-requester all >NIL:'
  297. return
  298.  
  299.  
  300. addlist: procedure
  301.   parse arg name
  302.   address command
  303.   'echo "" noline >"t:list-requester/'name'"'
  304. return
  305.  
  306.  
  307. picklist: procedure
  308.   parse arg titlestring
  309.   address spot
  310.   'requestfile title "'titlestring'" path t:list-requester'
  311.   name=result
  312.   if rc>0 then name='CANCELLED'
  313.  
  314.   separator=lastpos('/',name)
  315.   if separator=0 then separator=lastpos(':',name)
  316.   if separator=0 then basename=name
  317.   else basename=substr(name,separator+1)
  318.  
  319. return basename
  320.  
  321.  
  322. /***************************************************************************/
  323. /* Clean up                                                                */
  324. /***************************************************************************/
  325.  
  326. cleanup: procedure
  327.   address spot
  328.   'unlockgui'
  329.   call deletelist()
  330.   exit
  331. return
  332.