home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / GFX / ADPro251-3.DMS / ADPro251-3.adf / ADProScripts.lha / PingPongANIM.adpro < prev    next >
Encoding:
Text File  |  1994-01-31  |  5.0 KB  |  252 lines

  1. /*
  2. ** PingPongANIM.adpro
  3. **
  4. ** $VER: PingPongANIM.adpro 1.2.1 (17.1.94)
  5. **
  6. ** This AREXX program will take an existing ANIM file create a new
  7. ** PingPong anim from it.
  8. **
  9. ** This script requires ADPro v2.5.0 (or higher).
  10. **
  11. ** Copyright © 1990-1994 ASDG, Incorporated
  12. ** All Rights Reserved
  13. */
  14.  
  15.  
  16. ADDRESS "ADPro"
  17. OPTIONS RESULTS
  18.  
  19. NL = '0A'X
  20. SQ = '27'X
  21. DQ = '22'X
  22. TRUE  = 1
  23. FALSE = 0
  24. TempDefaults = "T:TempADProDefaults"
  25.  
  26.  
  27. /*
  28. ** Save the current environment.
  29. */
  30.  
  31. SAVE_DEFAULTS TempDefaults
  32.  
  33.  
  34. /*
  35. ** Select the file to ping-pong.
  36. */
  37.  
  38. CALL "FREDSCRIPTS:FREDFunctions/GetAFile" '"Enter ANIM to Ping Pong"' '"ADPRO:"' '""""' TRUE
  39. SrcANIMFName = RESULT
  40. IF (SrcANIMFName = DQ||DQ) THEN DO
  41.     ADPRO_TO_FRONT
  42.     OKAY1 "No source ANIM specified."
  43.     CALL ErrorOut 10
  44. END
  45.  
  46. ADPRO_TO_FRONT
  47.  
  48. OKAYN '"PingPongANIM"' '"Was this ANIM created with the wrap-up option?"' '"Yes|No|Cancel"'
  49. WrapCheck = RC
  50.  
  51. IF (WrapCheck = 0) THEN DO
  52.     CALL ErrorOut 10
  53. END
  54. ELSE IF (WrapCheck = 1) THEN
  55.     wrap = 1
  56. ELSE IF (WrapCheck = 2) THEN
  57.     wrap = 0
  58.  
  59.  
  60. /*
  61. ** Specify ANIM file to create.
  62. */
  63.  
  64. CALL "FREDSCRIPTS:FREDFunctions/GetAFile" '"Enter new ANIM to create"' '"ADPRO:"' '""""' TRUE
  65. DestANIMFName = RESULT
  66. IF (DestANIMFName = DQ||DQ) THEN DO
  67.     ADPRO_TO_FRONT
  68.     OKAY1 "No destination ANIM specified."
  69.     CALL ErrorOut 10
  70. END
  71.  
  72. IF (EXISTS( DestANIMFName )) THEN DO
  73.     ADPRO_TO_FRONT
  74.  
  75.     OKAYN '"PingPongANIM"' '"Truncate destination ANIM?"' '"Start New File|Append To File|Cancel"'
  76.     IF (RC = 0) THEN DO
  77.         CALL ErrorOut 10
  78.     END
  79.     ELSE IF (RC = 1) THEN DO
  80.         IMAGE_TYPE
  81.         ImageType = ADPRO_RESULT
  82.         IF (WORD( ImageType, 1 ) = "NONE") THEN DO
  83.             LOADER "BACKDROP" "XXX" "WIDTH" 10 "HEIGHT" 10 "COLOR"
  84.             IF (RC ~= 0) THEN DO
  85.                 ADPRO_TO_FRONT
  86.                 OKAY1 "Unable to create temp image." || NL ||,
  87.                     "Argument Information:" || NL||,
  88.                     "Width = " || 10 || NL ||,
  89.                     "Height = " || 10 || NL ||,
  90.                     "Type = " || "COLOR"
  91.                 CALL ErrorOut 10
  92.             END
  93.         END
  94.  
  95.         IF (WORD( ImageType, 1 ) ~= "BITPLANE") THEN DO
  96.             EXECUTE
  97.             IF (RC ~= 0) THEN DO
  98.                 ADPRO_TO_FRONT
  99.                 OKAY1 "Unable to create temp rendered data."
  100.                 CALL ErrorOut 10
  101.             END
  102.         END
  103.  
  104.         SAVER "ANIM" DestANIMFName "IMAGE" "QUIT" ANIMCompressType ANIMCompressQual
  105.         IF (RC ~= 0) THEN DO
  106.             ADPRO_TO_FRONT
  107.             OKAY1 "Could not close current ANIM file." || NL ||,
  108.                 "Argument Information:" || NL ||,
  109.                 "Filename = " || DestANIMFName || NL ||,
  110.                 "Type = " || "IMAGE" || NL ||,
  111.                 "Flags = " || "QUIT"
  112.             CALL ErrorOut 10
  113.         END
  114.  
  115.         ADDRESS COMMAND "Delete >NIL:" DestANIMFName
  116.     END
  117. END
  118.  
  119.  
  120. /*
  121. ** Get the compression mode.
  122. */
  123.  
  124. ADPRO_TO_FRONT
  125.  
  126. OKAYN '"PingPongANIM"' '"Select ANIM Compression"' '"BYTE|WORD|LONG|Cancel"'
  127. IF (RC = 0) THEN DO
  128.     CALL ErrorOut 10
  129. END
  130. ELSE IF (RC = 1) THEN
  131.     ANIMCompressType = "BYTE"
  132. ELSE IF (RC = 2) THEN
  133.     ANIMCompressType = "WORD"
  134. ELSE IF (RC = 3) THEN
  135.     ANIMCompressType = "LONG"
  136.  
  137.  
  138. /*
  139. ** Get the compression quality.
  140. */
  141.  
  142. ADPRO_TO_FRONT
  143.  
  144. OKAYN '"PingPongANIM"' '"Select Compression Quality"' '"Faster Compression|Smaller File Size|Cancel"'
  145. IF (RC = 0) THEN DO
  146.     CALL ErrorOut 10
  147. END
  148. ELSE IF (RC = 1) THEN
  149.     ANIMCompressQual = "FASTER"
  150. ELSE IF (RC = 2) THEN
  151.     ANIMCompressQual = "SMALLER"
  152.  
  153.  
  154. /*
  155. ** Perform operation.
  156. */
  157.  
  158. LOADER "ANIM" SrcANIMFName "COUNT"
  159. IF (RC ~= 0) THEN DO
  160.     ADPRO_TO_FRONT
  161.     OKAY1 "Can't find ANIM file."
  162.     CALL ErrorOut 10
  163. END
  164.  
  165. numframes = ADPRO_RESULT
  166.  
  167. ADDRESS COMMAND "Copy" SrcANIMFName DestANIMFName
  168.  
  169. IF (wrap ~= 0) THEN DO
  170.     numframes = numframes - 2
  171.     LOADER "ANIM" SrcANIMFName "FRAME" 1
  172.     IF (RC ~= 0) THEN DO
  173.         ADPRO_TO_FRONT
  174.         OKAY1 "Cannot load src anim frame 1."
  175.         CALL ErrorOut 10
  176.     END
  177.  
  178.     SAVER "ANIM" DestANIMFName "IMAGE" "TRUNCATE" numframes ANIMCompressType ANIMCompressQual 
  179.     IF (RC ~= 0) THEN DO
  180.         ADPRO_TO_FRONT
  181.         OKAY1 "Cannot create dest anim."
  182.         CALL ErrorOut 10
  183.         END
  184. END
  185.  
  186. num = numframes
  187. continue = 0
  188. DO WHILE (continue = 0)
  189.     LOADER "ANIM" SrcANIMFName "FRAME" num
  190.     IF (RC ~= 0) THEN DO
  191.         ADPRO_TO_FRONT
  192.         OKAY1 "Error during load."
  193.         CALL ErrorOut 10
  194.     END
  195.  
  196.     SAVER "ANIM" DestANIMFName "IMAGE" "APPEND"
  197.     IF (RC ~= 0) THEN DO
  198.         ADPRO_TO_FRONT
  199.         OKAY1 "Error during save."
  200.         CALL ErrorOut 10
  201.     END
  202.  
  203.     num = num - 1
  204.     IF (num < 1) THEN
  205.         continue = 1
  206. END
  207.  
  208. IF (wrap ~= 0) THEN
  209.     SAVER "ANIM" DestANIMFName "IMAGE" "WRAPUP" ANIMCompressType ANIMCompressQual
  210. ELSE
  211.     SAVER "ANIM" DestANIMFName "IMAGE" "QUIT" ANIMCompressType ANIMCompressQual
  212.  
  213. CALL ErrorOut 0
  214.  
  215.  
  216. ErrorOut:
  217.     PARSE ARG ExitCode
  218.  
  219.     IF (EXISTS( SrcANIMFName )) & (ErrorCode ~= 0) THEN DO
  220.         LOADER "ANIM" SrcANIMFName "QUIT"
  221.         IF (RC ~= 0) THEN DO
  222.             ADPRO_TO_FRONT
  223.             OKAY1 "Error closing source ANIM:" || NL ||,
  224.                 SrcANIMFName || NL || NL ||,
  225.                 "You need to close it" || NL ||,
  226.                 "manually."
  227.         END
  228.     END
  229.  
  230.     IF (EXISTS( DestANIMFName )) & (ErrorCode ~= 0) THEN DO
  231.         SAVER "ANIM" DestANIMFName "IMAGE" "QUIT"
  232.         IF (RC ~= 0) THEN DO
  233.             ADPRO_TO_FRONT
  234.             OKAY1 "Error closing dest ANIM:" || NL ||,
  235.                 DestANIMFName || NL || NL ||,
  236.                 "You need to close it" || NL ||,
  237.                 "manually."
  238.         END
  239.     END
  240.  
  241.     IF (EXISTS( TempDefaults )) THEN DO
  242.         LOAD_DEFAULTS TempDefaults
  243.         IF (RC ~= 0) THEN DO
  244.             ADPRO_TO_FRONT
  245.             OKAY1 "Error restoring settings."
  246.         END
  247.  
  248.         ADDRESS COMMAND "Delete >NIL:" TempDefaults
  249.     END
  250.  
  251.     EXIT ExitCode
  252.