home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Exec 3 / CD_Magazyn_EXEC_nr_3.iso / Recent / biz / haage / ArtEffect4Demo.lha / ArtEffect4-Demo / Rexx / VAnim.rexx < prev   
OS/2 REXX Batch file  |  1998-05-29  |  6KB  |  157 lines

  1. /******************************************************************/
  2. /*                                                                */
  3. /*                VAnim.rexx V1.1 for ArtEffect 2.5.x             */
  4. /*                                                                */
  5. /* This rexxscript assembles a series of pictures to form a       */
  6. /* TransferAnim for Voyager or IBrowse.                           */
  7. /*                                                                */
  8. /* Written by: Eike M. Lang <elang@online-club.de>                */
  9. /* Homepage:   http://jayhawk.home.pages.de/                      */
  10. /*                                                                */
  11. /* Usage: create a number of pictures of equal size that will be  */
  12. /* the frames of the animation.  These pictures must be numbered  */
  13. /* consistently.                                                  */
  14. /* The name format for the frames MUST be <filename>.xxxx         */
  15. /* Where xxxx can be anything between 0000 and 9999               */
  16. /* <filename> can be any AmigaDOS-legal file name.                */
  17. /* Run the script from the shell or directly from ArtEffect.      */
  18. /* You can freely choose the start- and end-frames, but naturally */
  19. /* all frames in between those should exist.                      */
  20. /* Once the animation is assembled you are given the choice of    */
  21. /* saving it immediately.                                         */
  22. /*                                                                */
  23. /* The script tries to cover all common error-situations, but if  */
  24. /* you try hard enough, you'll still be able to mess it up.       */
  25. /* So don't get fancy and try to use anim-frames of different     */
  26. /* sizes (which would also look funny in Voyager and IBrowse) and */
  27. /* don't try to use your C sources or anything like that as anim  */
  28. /* frames.                                                        */
  29. /*                                                                */
  30. /* This script is freeware which means I retain full copyright    */
  31. /* on it. Permission is granted to Haage&Partner GmbH to include  */
  32. /* this script with ArtEffect.                                    */
  33. /*                                                                */
  34. /******************************************************************/
  35.  
  36. OPTIONS RESULTS
  37. OPTIONS FAILAT 21
  38. SIGNAL ON ERROR
  39.  
  40. /* Check for ArtEffect ARexx port */
  41. IF ~SHOW(P,"ArtEffect") THEN DO
  42.         SAY D2C(7)
  43.         SAY "ATTENTION:"
  44.         SAY "Could not find ArtEffect ARexx port."
  45.         SAY "Please make sure that ArtEffect is running."
  46.         SAY
  47.         EXIT
  48. END
  49.  
  50. ADDRESS "ArtEffect"
  51.  
  52.  
  53.  
  54. /* keep the user from interfering */
  55. LOCKGUI
  56.  
  57. /* Find out path and name of the first and last picture */
  58. REQUESTFILE VAR firstfile TITLE '"Select the first picture"'
  59. picpath=Left(firstfile, LastPos('/',firstfile))
  60. REQUESTFILE VAR lastfile PATH picpath TITLE '"Select the last picture"'
  61.  
  62. /* Load the last picture to be used */
  63. LOADBRUSH lastfile
  64. IF RC~=0 THEN
  65.         CALL NOTIFY("File" lastfile "could not be found.")
  66.  
  67. /* get width/height of the frames */
  68. GET STEM brush. BRUSHINFO
  69.  
  70. /* assign some variables we need */
  71. /* This is the base name of the variable without the number extension */
  72. stemname=Left(firstfile, Pos('.', firstfile))
  73.  
  74. /* This is the number of the first image to use */
  75. startnumber=Right(firstfile, Length(firstfile)-LastPos('.', firstfile))
  76.  
  77. /* This is the number of the last image to use */
  78. endnumber=Right(lastfile, Length(lastfile)-LastPos('.', lastfile))
  79.  
  80. /* Now calculate the total width of the animation */
  81. totalwidth=brush.width*(endnumber-startnumber+1)
  82.  
  83. /* Sanity check */
  84. IF totalwidth<1 THEN
  85.         NOTIFY("The last file must have a greater|number than the first one.")
  86.  
  87. /* Generate a new project with the right size */
  88. NEW WIDTH totalwidth HEIGHT brush.height NAME "TransferAnim"
  89.  
  90. /* Main loop */
  91. DO i=0 TO (endnumber-startnumber)
  92.  
  93.         /* calculate the current file for this cycle */
  94.         currfile=stemname || Right(i+startnumber, 4, 0)
  95.  
  96.         /* attempt to load it */
  97.         LOADBRUSH currfile
  98.  
  99.         /* Check existence of each file */
  100.         IF RC~=0 THEN
  101.                 CALL NOTIFY("File" currfile "could not be found.|Please make sure all files between|" firstfile "and" lastfile "exist.")
  102.  
  103.         /* Make position caculation as easy as possible */
  104.         CHANGEBRUSH HANDLE TOPLEFT
  105.  
  106.         /* Finally put the image on the page */
  107.         PLOT i*brush.width 0 PT PEN MODE MATTE STR 100
  108. END
  109.  
  110. /* Give the user the chance to save his creation right away */
  111. REQUESTRESPONSE VAR choice TITLE '"User Query"' PROMPT '"Do you want to save this animation?"' OPTIONS "Yes|No|Don't Know"
  112.  
  113. /* Save-file feat. full(?) sanity-check */
  114. IF choice=0 THEN DO
  115.         REQUESTFILE VAR saveanim TITLE '"Save Animation"' FILE "TransferAnim"
  116.         SAVE
  117.         IF RC~=0 THEN
  118.                 CALL NOTIFY("You cancelled the saving process.")
  119.         SAVEPIC NAME saveanim PLUGIN IFF-ILBM
  120.         IF RC~=0 THEN
  121.                 CALL NOTIFY("File" savenanim "could not be saved.")
  122. END
  123.  
  124. /* Notify user that he can save the file at a later time */
  125. ELSE REQUESTNOTIFY TITLE "Message" OK '"I see"' PROMPT "You can still save the|animation manually."
  126.  
  127. /* return control to user */
  128. UNLOCKGUI
  129.  
  130. EXIT
  131.  
  132. /* Error notification - saves a few lines of rexx code */
  133. NOTIFY:
  134.         /* Get the actual error */
  135.         PARSE ARG Errorstring
  136.  
  137.         /* Notify user via the ArtEffect-provided requester */
  138.         REQUESTNOTIFY TITLE "Error" PROMPT Errorstring
  139.  
  140.         /* always make sure the GUI is unlocked after errors */
  141.         UNLOCKGUI
  142.         EXIT
  143. RETURN
  144.  
  145. /* Handling of errors that are not intercepted by the script itself
  146.      The most common situation for this message to appear is that the
  147.      user did not follow the naming conventions for the frames.
  148.      This error will of course also occur when trying to load files of
  149.      the wrong format - ASCII, binaries, etc. ;-) */
  150.  
  151. ERROR:
  152.         REQUESTNOTIFY TITLE "ARexx-Error" PROMPT "ARexx-error no." RC "has occured in line" SIGL ".|Please make sure the pictures are properly named|and numbered."
  153.         UNLOCKGUI
  154. EXIT
  155.  
  156.  
  157.