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

  1. /*
  2. ** BustANIM.adpro
  3. **
  4. ** $VER: BustANIM.adpro 1.3.0 (17.11.93)
  5. **
  6. ** This AREXX program will take an existing ANIM file and bust it
  7. ** apart into individual frames.
  8. **
  9. ** This script requires ADPro v2.5.0 (or higher).
  10. **
  11. ** Copyright © 1990-1993 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 bust into frames.
  39. */
  40.  
  41. CALL "FREDSCRIPTS:FREDFunctions/GetAFile" '"Enter ANIM to bust up"' '"ADPRO:"' '""""' TRUE
  42. fname = RESULT
  43. IF (fname = DQ||DQ) THEN DO
  44.     ADPRO_TO_FRONT
  45.     OKAY1 "No ANIM specified."
  46.     CALL ErrorOut 10
  47. END
  48.  
  49.  
  50. /*
  51. ** Strip the device name.
  52. */
  53.  
  54. name = RIGHT( fname, LENGTH( fname ) - INDEX( fname, ':' ))
  55.  
  56. /*
  57. ** Strip the path name.
  58. */
  59.  
  60. name = RIGHT( name, LENGTH( name ) - LASTPOS( '/', name ))
  61.  
  62.  
  63. /*
  64. ** Ask about ANIM settings.
  65. */
  66.  
  67. ADPRO_TO_FRONT
  68.  
  69. OKAYN '"BustANIM"' '"Was this ANIM created with the Wrap-Up Option?"' '"Yes|No|Cancel"'
  70. WrapCheck = RC
  71.  
  72. IF (WrapCheck = 0) THEN DO
  73.     CALL ErrorOut 10
  74. END
  75. ELSE IF (WrapCheck = 1) THEN
  76.     wrap = 1
  77. ELSE IF (WrapCheck = 2) THEN
  78.     wrap = 0
  79.  
  80.  
  81. /*
  82. ** Ask where the frames should be placed.
  83. */
  84.  
  85. CALL GetDestDir
  86.  
  87. ADPRO_TO_FRONT
  88.  
  89. OKAYN '"BustANIM"' '"Frame type?"' '"24-Bit|ANIM-type|Cancel"'
  90. FrameCheck = RC
  91.  
  92. IF (FrameCheck = 0) THEN DO
  93.     CALL ErrorOut 10
  94. END
  95. ELSE IF (FrameCheck = 1) THEN
  96.     stype = 1
  97. ELSE IF (FrameCheck = 2) THEN
  98.     stype = 0
  99.  
  100. LOADER "ANIM" fname "COUNT"
  101. IF (RC ~= 0) THEN DO
  102.     ADPRO_TO_FRONT
  103.     OKAY1 "Can't find ANIM file."
  104.     CALL ErrorOut 10
  105. END
  106.  
  107. NumFrames = ADPRO_RESULT
  108. IF (wrap ~= 0) THEN
  109.     NumFrames = NumFrames - 2
  110.  
  111.  
  112. /*
  113. ** Ask which frames to process.
  114. */
  115.  
  116. CALL "FREDSCRIPTS:FREDFunctions/GetANumber" '"Starting frame"' 1 1 NumFrames TRUE
  117. StartFrame = RESULT
  118. IF (StartFrame = (1-1)) THEN
  119.     CALL ErrorOut 10
  120.  
  121. CALL "FREDSCRIPTS:FREDFunctions/GetANumber" '"Ending frame"' NumFrames StartFrame NumFrames TRUE
  122. EndFrame = RESULT
  123. IF (EndFrame = (StartFrame-1)) THEN
  124.     CALL ErrorOut 10
  125.  
  126.  
  127. /*
  128. ** Perform the busting.
  129. */
  130.  
  131. continue = FALSE
  132. num = StartFrame
  133. DO WHILE (continue = FALSE)
  134.     LOADER "ANIM" fname "FRAME" num
  135.     IF (RC ~= 0) THEN DO
  136.         ADPRO_TO_FRONT
  137.         OKAY1 "Error during load" || NL ||,
  138.             "of frame " || num || "."
  139.         CALL ErrorOut 10
  140.     END
  141.     IF (stype ~= 0) THEN
  142.         opt = "RAW"
  143.     ELSE
  144.         opt = "IMAGE"
  145.  
  146.     continuesave = FALSE
  147.     DO UNTIL (continuesave = TRUE)
  148.         SAVER "IFF" dir || name || "." || RIGHT( num, 5, "0" ) opt
  149.         IF (RC ~= 0) THEN DO
  150.             text = "Error saving frame " || num || "."
  151.  
  152.             ADPRO_TO_FRONT
  153.  
  154.             OKAYN '"BustANIM"' '"'text'"' '"Retry|Specify New Destination...|Cancel"'
  155.             IF (RC = 0) THEN
  156.                 CALL ErrorOut 10
  157.             ELSE IF (RC = 2) THEN
  158.                 CALL GetDestDir
  159.         END
  160.         ELSE
  161.             continuesave = TRUE
  162.     END
  163.  
  164.     num = num + 1
  165.     IF (num > EndFrame) THEN
  166.         continue = TRUE
  167. END
  168.  
  169. CALL ErrorOut 0
  170.  
  171.  
  172.  
  173.  
  174. GetDestDir:
  175.     CALL "FREDSCRIPTS:FREDFunctions/GetADir" '"Where should I place the frames?"' '"ADPRO:"' TRUE
  176.     dir = RESULT
  177.     IF (dir = DQ||DQ) THEN DO
  178.         ADPRO_TO_FRONT
  179.         OKAY1 "Error, no dest path specified."
  180.         CALL ErrorOut 10
  181.     END
  182.  
  183.     IF ((RIGHT( dir, 1 ) ~= '/') & (RIGHT( dir, 1 ) ~= ':')) THEN
  184.         dir = dir || '/'
  185.  
  186.     RETURN
  187.  
  188.  
  189.  
  190.  
  191. ErrorOut:
  192.     PARSE ARG ExitCode
  193.  
  194.     IF (EXISTS( fname )) & (ErrorCode ~= 0) THEN DO
  195.         LOADER "ANIM" fname "QUIT"
  196.         IF (RC ~= 0) THEN DO
  197.             ADPRO_TO_FRONT
  198.             OKAY1 "Error closing source ANIM:" || NL ||,
  199.                 fname || NL || NL ||,
  200.                 "You need to close it" || NL ||,
  201.                 "manually."
  202.         END
  203.     END
  204.  
  205.     IF (EXISTS( TempDefaults )) THEN DO
  206.         LOAD_DEFAULTS TempDefaults
  207.         IF (RC ~= 0) THEN DO
  208.             ADPRO_TO_FRONT
  209.             OKAY1 "Error restoring settings."
  210.         END
  211.  
  212.         ADDRESS COMMAND "Delete >NIL:" TempDefaults
  213.     END
  214.  
  215.     EXIT ExitCode
  216.