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

  1. /*
  2. ** ReverseANIM.adpro
  3. **
  4. ** $VER: ReverseANIM.adpro 1.3.1 (17.1.94)
  5. **
  6. ** This AREXX program will take an existing ANIM file and create a new
  7. ** anim that is reversed.
  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. PSTATUS "UNLOCKED"
  35.  
  36.  
  37. /*
  38. ** Select the file to reverse.
  39. */
  40.  
  41. CALL "FREDSCRIPTS:FREDFunctions/GetAFile" '"Enter ANIM To Reverse"' '"ADPRO:"' '""""' TRUE
  42. IF (RESULT = DQ||DQ) THEN DO
  43.     ADPRO_TO_FRONT
  44.     OKAY1 "Error, no source ANIM specified."
  45.     CALL ErrorOut 10
  46. END
  47. SrcANIMFName = RESULT
  48.  
  49. CALL "FREDSCRIPTS:FREDFunctions/GetAFile" '"Enter name of ANIM file to create"' '"ADPRO:"' '""""' TRUE
  50. IF (RESULT = DQ||DQ) THEN DO
  51.     ADPRO_TO_FRONT
  52.     OKAY1 "Error, no dest ANIM specified."
  53.     CALL ErrorOut 10
  54. END
  55. DestANIMFName = RESULT
  56.  
  57. IF (EXISTS( DestANIMFName )) THEN DO
  58.     ADPRO_TO_FRONT
  59.  
  60.     OKAYN '"ReverseANIM"' '"Truncate destination ANIM?"' '"Start New File|Append To File|Cancel"'
  61.     IF (RC = 0) THEN DO
  62.         CALL ErrorOut 10
  63.     END
  64.     ELSE IF (RC = 1) THEN DO
  65.         IMAGE_TYPE
  66.         ImageType = ADPRO_RESULT
  67.         IF (WORD( ImageType, 1 ) = "NONE") THEN DO
  68.             LOADER "BACKDROP" "XXX" "WIDTH" 10 "HEIGHT" 10 "COLOR"
  69.             IF (RC ~= 0) THEN DO
  70.                 ADPRO_TO_FRONT
  71.                 OKAY1 "Unable to create temp image." || NL ||,
  72.                     "Argument Information:" || NL||,
  73.                     "Width = " || 10 || NL ||,
  74.                     "Height = " || 10 || NL ||,
  75.                     "Type = " || "COLOR"
  76.                 CALL ErrorOut 10
  77.             END
  78.         END
  79.  
  80.         IF (WORD( ImageType, 1 ) ~= "BITPLANE") THEN DO
  81.             EXECUTE
  82.             IF (RC ~= 0) THEN DO
  83.                 ADPRO_TO_FRONT
  84.                 OKAY1 "Unable to create temp rendered data."
  85.                 CALL ErrorOut 10
  86.             END
  87.         END
  88.  
  89.         SAVER "ANIM" DestANIMFName "IMAGE" "QUIT"
  90.         IF (RC ~= 0) THEN DO
  91.             ADPRO_TO_FRONT
  92.             OKAY1 "Could not close current ANIM file." || NL ||,
  93.                 "Argument Information:" || NL ||,
  94.                 "Filename = " || DestANIMFName || NL ||,
  95.                 "Type = " || "IMAGE" || NL ||,
  96.                 "Flags = " || "QUIT"
  97.             CALL ErrorOut 10
  98.         END
  99.  
  100.         ADDRESS COMMAND "Delete >NIL:" DestANIMFName
  101.     END
  102. END
  103.  
  104. LOADER "ANIM" SrcANIMFName "COUNT"
  105. IF (RC ~= 0) THEN DO
  106.     ADPRO_TO_FRONT
  107.     OKAY1 "Can't find ANIM file."
  108.     CALL ErrorOut 10
  109. END
  110. NumFrames = ADPRO_RESULT
  111.  
  112.  
  113. /*
  114. ** Ask which frames to process.
  115. */
  116.  
  117. CALL "FREDSCRIPTS:FREDFunctions/GetANumber" '"Starting frame"' 1 1 NumFrames TRUE
  118. StartFrame = RESULT
  119. IF (StartFrame = (1-1)) THEN
  120.     CALL ErrorOut 10
  121.  
  122. CALL "FREDSCRIPTS:FREDFunctions/GetANumber" '"Ending frame"' NumFrames StartFrame NumFrames TRUE
  123. EndFrame = RESULT
  124. IF (EndFrame = (StartFrame-1)) THEN
  125.     CALL ErrorOut 10
  126.  
  127.  
  128. CurrFrameNum = EndFrame
  129. continue = FALSE
  130. DO WHILE (continue = FALSE)
  131.     LOADER "ANIM" SrcANIMFName "FRAME" CurrFrameNum
  132.     IF (RC ~= 0) THEN DO
  133.         ADPRO_TO_FRONT
  134.         OKAY1 "Error during load" || NL ||,
  135.             "of frame " || CurrFrameNum || "."
  136.         CALL ErrorOut 10
  137.     END
  138.  
  139.     SAVER "ANIM" DestANIMFName "IMAGE" "APPEND"
  140.     IF (RC ~= 0) THEN DO
  141.         ADPRO_TO_FRONT
  142.         OKAY1 "Error during save" || NL ||,
  143.             "of frame " || CurrFrameNum || "."
  144.         CALL ErrorOut 10
  145.     END
  146.  
  147.     CurrFrameNum = CurrFrameNum - 1
  148.     IF (CurrFrameNum < StartFrame) THEN
  149.         continue = FALSE
  150. END
  151.  
  152. SAVER "ANIM" DestANIMFName "IMAGE" "QUIT"
  153. IF (RC ~= 0) THEN DO
  154.     ADPRO_TO_FRONT
  155.     OKAY1 "Error when closing dest anim."
  156.     CALL ErrorOut 10
  157. END
  158.  
  159. CALL ErrorOut 0
  160.  
  161.  
  162. ErrorOut:
  163.     PARSE ARG ExitCode
  164.  
  165.     IF (EXISTS( SrcANIMFName )) & (ErrorCode ~= 0) THEN DO
  166.         LOADER "ANIM" SrcANIMFName "QUIT"
  167.         IF (RC ~= 0) THEN DO
  168.             ADPRO_TO_FRONT
  169.             OKAY1 "Error closing source ANIM:" || NL ||,
  170.                 SrcANIMFName || NL || NL ||,
  171.                 "You need to close it" || NL ||,
  172.                 "manually."
  173.         END
  174.     END
  175.  
  176.     IF (EXISTS( DestANIMFName )) & (ErrorCode ~= 0) THEN DO
  177.         SAVER "ANIM" DestANIMFName "IMAGE" "QUIT"
  178.         IF (RC ~= 0) THEN DO
  179.             ADPRO_TO_FRONT
  180.             OKAY1 "Error closing dest ANIM:" || NL ||,
  181.                 DestANIMFName || NL || NL ||,
  182.                 "You need to close it" || NL ||,
  183.                 "manually."
  184.         END
  185.     END
  186.  
  187.     IF (EXISTS( TempDefaults )) THEN DO
  188.         LOAD_DEFAULTS TempDefaults
  189.         IF (RC ~= 0) THEN DO
  190.             ADPRO_TO_FRONT
  191.             OKAY1 "Error restoring settings."
  192.         END
  193.  
  194.         ADDRESS COMMAND "Delete >NIL:" TempDefaults
  195.     END
  196.  
  197.     EXIT ExitCode
  198.