home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 13 / AACD13.ISO / AACD / Graphics / PPT / rexx / BatchProcess.prx < prev    next >
Text File  |  1999-12-27  |  4KB  |  215 lines

  1. /*
  2.     This is a simple batch-process script that allows
  3.     you to specify a directory and process all of them.
  4.  
  5.     Usage:
  6.     Put all files to be processed in one directory. Run script.
  7.  
  8.     Known bugs:
  9.  
  10.     - Image name is generated in all caps
  11.     - Does not remove previous prefix
  12.     - Supports only one effect
  13.     - Icons are also processed
  14.     - Stops on unknown files
  15.     - Does not inform user when finished.
  16.  
  17.     $Id: BatchProcess.prx,v 1.2 1999/12/27 21:45:33 jj Exp jj $
  18. */
  19.  
  20. /*-------------------------------------------------------------------*/
  21. /*  I suggest you use this header as-is and add your own code below  */
  22.  
  23. OPTIONS RESULTS
  24. SIGNAL ON ERROR
  25. IF ADDRESS() = REXX THEN DO
  26.     startedfromcli = 1
  27.     ADDRESS PPT
  28. END
  29. ELSE DO
  30.     startedfromcli = 0
  31.     ADDRESS PPT
  32. END
  33. RESULT = 'no result'
  34.  
  35. /*-------------------------------------------------------------------*/
  36.  
  37. tmpfile = "T:ppt_batch_files.tmp"
  38.  
  39. ASKFILE '"Please give image directory"' DIRONLY
  40. dirname = RESULT
  41.  
  42. ADDRESS COMMAND
  43. SAY "Source directory is: " dirname
  44. 'list ' dirname ' >' tmpfile ' QUICK NOHEAD LFORMAT=%s%s'
  45. ADDRESS PPT
  46.  
  47. ASKFILE '"Give destination directory"' DIRONLY SAVE INITIALDRAWER "T:"
  48. destdir = RESULT
  49.  
  50. CALL geteffectname
  51. effectname = RESULT
  52.  
  53. GETARGS PLUGIN effectname
  54. effectargs = RESULT
  55.  
  56. SAY "Using arguments for module " effectname ":" effectargs
  57.  
  58. CALL getiomodulename
  59. iomodulename = RESULT
  60.  
  61. GETARGS PLUGIN iomodulename
  62. formatargs = RESULT
  63.  
  64. SAY "Using arguments for module " iomodulename ":" formatargs
  65.  
  66. IF open( file, tmpfile, 'Read' ) THEN DO
  67.  
  68.     DO WHILE ~eof(file)
  69.         filename = readln(file)
  70.  
  71.         SAY 'Loading 'filename
  72.  
  73.         LOADFRAME filename
  74.         myframe = RESULT
  75.  
  76.         PROCESS myframe effectname effectargs
  77.  
  78.         FRAMEINFO myframe STEM infostem
  79.  
  80.         CALL savefilename( iomodulename, infostem.name )
  81.         destfile = RESULT
  82.  
  83.         destpath = destdir || destfile
  84.  
  85.         SAVEFRAMEAS myframe destpath FORMAT iomodulename formatargs
  86.  
  87.         DELETEFRAME myframe FORCE
  88.     END
  89. END
  90.  
  91. EXIT 0
  92.  
  93. savefilename : PROCEDURE
  94.     ARG fileformat, filename
  95.  
  96.     IOMODULEINFO fileformat STEM iomodinfo
  97.     postfix = iomodinfo.preferredpostfix
  98.  
  99.     /* RETURN filename || postfix */
  100.     return filename || postfix
  101.  
  102. /*
  103.  *  geteffectname : returns the name of an effect.  Arguments:
  104.  *      none.
  105.  */
  106.  
  107. geteffectname : PROCEDURE
  108.  
  109.     /*
  110.         Gather a list of effects available that support
  111.         the GetArgs command
  112.      */
  113.  
  114.     LISTEFFECTS STEM effectlist
  115.  
  116.     FX = 1
  117.  
  118.     DO I = 1 TO effectlist.0
  119.  
  120.         EFFECTINFO effectlist.i STEM effectname
  121.  
  122.         IF effectname.getargs ~= 0 THEN DO
  123.             getarglist.FX = effectname.name
  124.             FX = FX+1
  125.         END
  126.     END
  127.  
  128.     getarglist.0 = FX - 1
  129.  
  130.     /*
  131.         Show the list to the user and ask which effect he wishes to perform.
  132.      */
  133.  
  134.     DO i = 1 TO getarglist.0
  135.         IF i = 1 THEN
  136.             effectgad.labels = getarglist.i
  137.         ELSE
  138.             effectgad.labels = effectgad.labels || "|" || getarglist.i
  139.     END
  140.  
  141.     effectgad.type = CYCLE
  142.     effectgad.popup = 1
  143.  
  144.     ASKREQ '"Please choose an effect"' effectgad
  145.     res = RESULT
  146.  
  147.     IF res ~= 0 THEN
  148.         EXIT 0 /* User cancelled */
  149.  
  150.     whichfx = effectgad.value + 1
  151.     effectname = getarglist.whichfx
  152.  
  153.     return effectname
  154.  
  155. getiomodulename : PROCEDURE
  156.  
  157.     LISTIOMODULES STEM iomodlist
  158.  
  159.     FX = 1
  160.  
  161.     DO I = 1 TO iomodlist.0
  162.  
  163.         IOMODULEINFO iomodlist.i STEM iomodname
  164.  
  165.         IF iomodname.getargs ~= 0 THEN DO
  166.             getarglist.FX = iomodname.name
  167.             FX = FX+1
  168.         END
  169.     END
  170.  
  171.     getarglist.0 = FX - 1
  172.  
  173.     /*
  174.         Show the list to the user and ask which effect he wishes to perform.
  175.      */
  176.  
  177.     DO i = 1 TO getarglist.0
  178.         IF i = 1 THEN
  179.             iomodgad.labels = getarglist.i
  180.         ELSE
  181.             iomodgad.labels = iomodgad.labels || "|" || getarglist.i
  182.     END
  183.  
  184.     iomodgad.type = CYCLE
  185.     iomodgad.popup = 1
  186.  
  187.     ASKREQ '"Please choose a saver module"' iomodgad
  188.     res = RESULT
  189.  
  190.     IF res ~= 0 THEN
  191.         EXIT 0 /* User cancelled */
  192.  
  193.     whichio = iomodgad.value + 1
  194.     iomodname = getarglist.whichio
  195.  
  196.     return iomodname
  197.  
  198.  
  199. /*-------------------------------------------------------------------*/
  200. /* Again, keep this part intact. This is the error handler. */
  201. ERROR :
  202.  
  203. ADDRESS PPT
  204. returncode = RC
  205. IF startedfromcli = 1 THEN DO
  206.     SAY 'ERROR ' returncode ' on line ' SIGL ': ' RC2
  207.     PPT_TO_BACK
  208. END
  209. ELSE
  210.     SHOWERROR '"'RC2'"' SIGL
  211. EXIT returncode
  212.  
  213.  
  214.  
  215.