home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 2 / goldfish_vol2_cd1.bin / files / comm / fido / spot / rexx / snapfiles.spot < prev    next >
Text File  |  1994-01-22  |  5KB  |  221 lines

  1. /* SnapFiles V1.1 By Glenn Wihlborg (2:200/600.39@Fidonet)
  2.  
  3.  * Tries to find possible filenames in messages.
  4.  
  5.  * $VER: SnapFiles 1.1 (1.21.94)
  6.  
  7.  * SnapFiles is offered to you under the concepts of Netmailware. That means
  8.    if you are using this in a period of 30 days, I would lika a Netmail
  9.    from you  :):):):) 
  10.  
  11.  * NOTICE!! You must have T: assigned to somewhere in your system */
  12.  
  13. IF ~SHOW(Libraries,'rexxsupport.library') THEN
  14.     IF ~ADDLIB("rexxsupport.library",0,-30,0) THEN DO
  15.         EXIT
  16.     END
  17.  
  18. ADDRESS Spot
  19. OPTIONS Results
  20.  
  21. SIGNAL ON BREAK_C
  22. SIGNAL ON SYNTAX
  23. SIGNAL ON FAILURE
  24.  
  25. Pathname = 'Outbound:' /* Path to your outbound dir, Must end with ':' or '/' */
  26.  
  27. LF ='0d'x  /* Line feed */
  28.  
  29. FileHit = 0 /* If there are any possible files I will set this to one */
  30.  
  31. FileLen = 0 /* Length of temporary file, used with progressupdate */
  32. LineLen = 0 /* Length of one line in temp file used with progrssupdate */
  33.  
  34. Total = 0  /* Total files found */
  35. NumExt = 7 /* Total extensions to search for */
  36.  
  37. Ext.1 = ".ZIP" /* Predefined extensions */
  38. Ext.2 = ".LHA" /* If you put in or remove extensions */
  39. Ext.3 = ".LZH" /* you MUST change the 'NumExt' variable to the */
  40. Ext.4 = ".ARJ" /* right value */
  41. Ext.5 = ".ZOO"
  42. Ext.6 = ".DMS"
  43. Ext.7 = ".ARC"
  44.  
  45. 'ismessages' /* Are we in messages? */
  46.  
  47. IF RC>0 THEN DO
  48.    Note = 'Use in message window only!'
  49.    CALL Notify()
  50.    EXIT
  51. END
  52. 'lockgui'
  53. 'getfromaddress'
  54. From = Result
  55.  
  56. 'requestresponse TITLE "SnapFiles V1.1" PROMPT "Use Which Nodenumber?"
  57. CENTER GADGETS _From|_Boss|_Other|_Cancel'
  58.  
  59. IF RC = 0 THEN DO
  60.    'unlockgui'
  61.    EXIT
  62. END
  63. /* Strip from address e.g. 2:200/600.39 to 2.200.600.39 */
  64. IF RC = 1 THEN DO
  65.    Zon = LEFT(From,POS(':',From)-1)
  66.    From = DELSTR(From,1,POS(':',From))
  67.    Net = LEFT(From,POS('/',From)-1)
  68.    From = DELSTR(From,1,POS('/',From))
  69.    Node = From
  70.    Out = Pathname||Zon||.||Net||.||Node||'.Req'
  71.    CALL Start()
  72. END
  73. /* Strip from address e.g. 2:200/600.39 to 2.200.600.0 */
  74. IF RC = 2 THEN DO
  75.    Zon = LEFT(From,POS(':',From)-1)
  76.    From = DELSTR(From,1,POS(':',From))
  77.    Net = LEFT(From,POS('/',From)-1)
  78.    From = DELSTR(From,1,POS('/',From))
  79.    Node = LEFT(From,POS('.',From))
  80.    Out = Pathname||Zon||.||Net||.||Node||0||'.Req'
  81.    CALL Start()
  82. END
  83. /* Use announcer's nodenumber */
  84. IF RC = 3 THEN DO
  85.    'requeststring TITLE "New Nodenumber" PROMPT "Format: Z.N.N.P"'
  86.    Other = Result
  87.    Out =  Pathname||Other||'.Req'
  88.    CALL Start()
  89. END
  90.  
  91. Start:
  92. 'saveascii TO "T:SnapFiles.tmp" OVERWRITE NOHEADER NOKLUDGES NOTEARLINE NOORIGIN'
  93.     IF ~OPEN('Input','T:SnapFiles.tmp', 'READ') THEN DO  /* Temp file */
  94.       Note = 'Unable to open T:SnapFiles.tmp'
  95.       CALL Notify()
  96.       'unlockgui'
  97.       EXIT
  98.    END
  99. ELSE
  100.    FileLen = WORD(STATEF("T:SnapFiles.tmp"),2)  /* Get size of file */
  101.    'progressopen TITLE "SnapFiles V1.1"
  102.    PROMPT "Scanning for possible filename(s)"'
  103.    Prequest = Result
  104.    StartTime = TIME('R')  /* Start timer */
  105.    DO WHILE ~EOF('Input')
  106.       Line = READLN('Input')
  107.       LineLen = LENGTH(Line)
  108.       FileLen = FileLen - LineLen
  109.       'progressupdate' Prequest LineLen FileLen
  110.          IF RC = 5 THEN DO
  111.             CALL BailOut()
  112.          END
  113.       DO x = 1 to WORDS(Line)
  114.          Hit = WORD(Line,x)
  115.          WordPos = LASTPOS('.',Hit)
  116.             IF RIGHT(Hit,1) ~= '.' & WordPos < 1 THEN DO
  117.             END
  118.          ELSE
  119.             DO a = 1 to NumExt
  120.             IF UPPER(RIGHT(Hit,4)) == Ext.a THEN DO
  121.                Total = Total + 1
  122.                CALL WriteReq()
  123.             LEAVE
  124.          END
  125.       END
  126.    END
  127. END
  128. 'progressclose' Prequest
  129.  
  130. EndTime = TIME('E')
  131. TotalTime = (EndTime - StartTime)
  132. CALL CLOSE('Input')
  133. address command 'delete >NIL: T:SnapFiles.tmp'   /* Delete temp file */
  134.  
  135. 'unlockgui'
  136.  
  137. IF FileHit ~= 1 THEN DO  /* Did we find any filenames? */
  138.    Note = 'No Possible files!!'LF'Operation took 'TotalTime' Sec.'
  139.    CALL Notify()
  140.    EXIT
  141. END
  142. ELSE
  143. Request = 'All done found 'Total' File(s)'LF'Operation took 'TotalTime' Sec.'LF'Edit the ReqFile?'
  144. CALL Request()
  145.  
  146. WriteReq:
  147. FileHit = 1 /* Found one or more files */
  148.  
  149. IF ~EXISTS(Out) THEN DO
  150.    IF ~OPEN('FileReq',Out,'W') THEN DO
  151.       'progressclose' Prequest
  152.       'unlockgui'
  153.       Note = 'Can not create Req file: 'Out'.'
  154.       CALL Notify()
  155.       EXIT
  156.    END
  157.    ELSE
  158.       CALL WRITELN('FileReq',Hit)
  159.       CALL CLOSE('FileReq')
  160.       RETURN
  161.    END
  162. ELSE
  163.    IF ~OPEN('FileReq',Out,'A') THEN DO
  164.       'progressclose' Prequest
  165.       'unlockgui'
  166.       Note = 'Can not open Req file: 'Out'.'
  167.       CALL Notify()
  168.       EXIT
  169.    END
  170.    ELSE
  171.       CALL WRITELN('FileReq',Hit)
  172.       CALL CLOSE('FileReq')
  173.    RETURN
  174. END
  175.  
  176. BailOut:  /* --- If user stops the operation, check this --- */
  177. 'progressclose' Prequest
  178. 'unlockgui'
  179. CALL CLOSE('Input')
  180. address command 'delete >NIL: T:SnapFiles.tmp'   /* Delete temp file */
  181.  
  182. IF FileHit ~= 1 THEN DO  /* Did we find any filenames ? */
  183.    Note = 'Bailing out!!'LF'Found No Possible file names.'
  184.    CALL Notify()
  185.    EXIT
  186. END
  187. ELSE
  188. Request = 'Bailing out!!'LF'Possible File(s) 'Total''LF'Edit the ReqFile?'
  189. CALL Request()
  190.  
  191. Notify:
  192. 'requestnotify PROMPT "'Note'" CENTER'
  193. RETURN
  194.  
  195. Request:
  196. 'requestresponse TITLE "SnapFiles V1.1" PROMPT "'Request'"
  197. CENTER GADGETS _Edit|_Delete|_No'
  198.  
  199. IF RC = 0 THEN DO
  200.    EXIT
  201. END
  202. IF RC = 1 THEN DO
  203.    'filerequest'
  204.    EXIT
  205. END
  206. IF RC = 2 THEN DO
  207.    address command delete Out
  208.    EXIT
  209. END
  210.  
  211. /* --- Error handler (Hopefully it will not be used :) ) --- */
  212. BREAK_C:
  213. SYNTAX:
  214. FAILURE:
  215. 'progressclose' Prequest
  216. 'unlockgui'
  217. Note = ''Errortext(RC) 'at line' SIGL''
  218. CALL Notify()
  219. EXIT
  220. END
  221.