home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 2 / FFMCD02.bin / new / comm / fido / spot / rexx / filehatch.spot < prev    next >
Text File  |  1993-12-21  |  11KB  |  305 lines

  1. /***************************************************************************/
  2. /*                                                                         */
  3. /* FileHatch.spot     ©1993 Stefan Zeiger     2:244/6302.15@fidonet        */
  4. /*                                                                         */
  5. /* $VER: FileHatch.spot 1.5 (24.9.93)                                      */
  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. /*                                                                         */
  36. /***************************************************************************/
  37.  
  38.  
  39. fhatch_path   = 'mail:bin/FHatch'
  40. ftick_cfg     = 'mail:tick.cfg'
  41.  
  42. skytick_path  = 'mail:skytick/SkyTick'
  43. skytick_cfg   = 'mail:sky'                /*  -> mail:skyTICK.CFG */
  44.  
  45. used_program  = 'fhatch'                /* [fhatch|skytick|none] */
  46.  
  47. from_name     = 'Stefan Zeiger'
  48. host_name     = '2:244/6302.15'
  49. to_name       = 'All'
  50. subj_line     = 'File Arrival Announcement'
  51. origin        = 'FileHatch.spot, (c) 1993 by Stefan Zeiger'
  52. use_origin    = 'yes'
  53.  
  54. temp_file     = 'T:FileHatch.spot.TMP'
  55. temp_dir      = 'T:'
  56. spot_path     = 'sys:comm/spot/Spot'
  57.  
  58. file_path     = 'outgoing:'
  59. keep_original = 'yes'
  60.  
  61. call newlist()
  62. call addlist('SPOT_BETA')
  63. call addlist('UPLOAD.ALLG')
  64. call addlist('UPLOAD.AMIGA')
  65. call addlist('UPLOAD.DTP')
  66. call addlist('UPLOAD.MOD')
  67. call addlist('UPLOAD.PIX')
  68. call addlist('UPLOAD.RAY')
  69.  
  70.  
  71. /***************************************************************************/
  72. /* Set up system                                                           */
  73. /***************************************************************************/
  74.  
  75. options results
  76.  
  77. CR = '0d'x
  78.  
  79. if ~show(l, 'rexxsupport.library') then do
  80.   if ~addlib('rexxsupport.library', 0, -30) then do
  81.     say 'Please install the rexxsupport.library in your libs: directory'
  82.   end
  83. end
  84.  
  85. if ~show('ports','SPOT') then do
  86.   address command spot_path
  87.   'WaitForPort SPOT'
  88.   if rc = 5 then do
  89.     call cleanup()
  90.   end
  91.   quit = 'yes'
  92. end
  93.  
  94. 'isiconified'
  95. if rc = 0 then do
  96.   icon = 'yes'
  97.   'uniconify'
  98. end
  99.  
  100.  
  101. /***************************************************************************/
  102. /* Ask for the file, areas and description                                 */
  103. /***************************************************************************/
  104.  
  105. address spot
  106.  
  107. 'requestfile title "Hatch file..." path 'file_path
  108. if rc>0 then call cleanup()
  109. hatchfile=result
  110.  
  111. filearea_name=picklist("Hatch in...")
  112. if filearea_name='CANCELLED' then call cleanup()
  113. if filearea_name='' then call cleanup()
  114.  
  115. 'requestarea title "Announce in..."'
  116. if rc>0 then call cleanup()
  117. echo_name=result
  118.  
  119. address command
  120. call statef(hatchfile)
  121. parse var result dummy filelength dummy dummy dummy dummy dummy description
  122. description=substr(description,2)
  123.  
  124. address spot
  125.  
  126. 'requeststring title "Description..." prompt "Please enter the description" center default "'description'"'
  127. if rc>0 then call cleanup()
  128. description=result
  129.  
  130.  
  131. /***************************************************************************/
  132. /* Create the announcement                                                 */
  133. /***************************************************************************/
  134.  
  135. address command
  136.  
  137. call delete(temp_file)
  138. hatchdate=date()', 'time()
  139. separator=lastpos('/',hatchfile)
  140. if separator=0 then separator=lastpos(':',hatchfile)
  141. if separator=0 then hatchfile_base=hatchfile
  142. else hatchfile_base=substr(hatchfile,separator+1)
  143.  
  144. call open('TEMP',temp_file,'W')
  145. call writeln('TEMP','')
  146. call writeln('TEMP','')
  147. call writeln('TEMP',' The following file has just been hatched at 'host_name' :')
  148. call writeln('TEMP','')
  149. call writeln('TEMP','')
  150. call writeln('TEMP',' File name   : 'hatchfile_base)
  151. call writeln('TEMP',' Length      : 'filelength)
  152. call writeln('TEMP',' Description : 'description)
  153. call writeln('TEMP',' File area   : 'filearea_name)
  154. call writeln('TEMP',' Origin      : 'host_name)
  155. call writeln('TEMP',' Date, Time  : 'hatchdate)
  156. call writeln('TEMP','')
  157. call writeln('TEMP','')
  158. call writeln('TEMP',' Information supplied by FileHatch.spot 1.5  (c) 1993 by Stefan Zeiger')
  159. call writeln('TEMP','')
  160. call close('TEMP')
  161.  
  162.  
  163. /***************************************************************************/
  164. /* Hatch the file                                                          */
  165. /***************************************************************************/
  166.  
  167. select
  168.   when used_program='skytick' then call hatch_with_skytick()
  169.   when used_program='fhatch' then call hatch_with_fhatch()
  170.   otherwise nop
  171. end
  172.  
  173.  
  174. /***************************************************************************/
  175. /* Write the file announcement message into the specified area             */
  176. /***************************************************************************/
  177.  
  178. address spot
  179. 'lockgui'
  180. 'arealist'
  181. 'gotoarea NAME 'echo_name
  182. if rc ~= 0 then do
  183.   'requestnotify PROMPT "Could not find area'||CR||echo_name'"'
  184.   call cleanup()
  185. end
  186. 'messagelist'
  187. if use_origin='yes' then 'write TO "'to_name'" FROM "'from_name'" SUBJECT "'subj_line'" FILE 'temp_file' ORIGIN "'origin'" NOEDIT NOGUI NOSIG'
  188. else 'write TO "'to_name'" FROM "'from_name'" SUBJECT "'subj_line'" FILE 'temp_file' NOEDIT NOGUI NOSIG'
  189. 'arealist'
  190. 'unlockgui'
  191.  
  192.  
  193. /***************************************************************************/
  194. /* Exit gracefully                                                         */
  195. /***************************************************************************/
  196.  
  197. if icon = 'yes' then do
  198.   'iconify NOREQ'
  199. end
  200.  
  201. if quit = 'yes' then do
  202.   'quitspot NOREQ'
  203. end
  204.  
  205. call delete(temp_file)
  206. call deletelist()
  207.  
  208. call cleanup()
  209.  
  210.  
  211. /***************************************************************************/
  212. /* Hatch the file using FHatch                                             */
  213. /***************************************************************************/
  214.  
  215. hatch_with_fhatch:
  216.  
  217.   address command
  218.  
  219.   if keep_original='yes' then 'copy 'hatchfile' to 'temp_dir||hatchfile_base' clone'
  220.  
  221.   fhatch_path' "'ftick_cfg'" "'hatchfile'" 'filearea_nam