/* ----------------------------------------------------------------
   --ImageStudio.animGIF export AREXX script version 1.2 8.7.97  --
   --written by Brett Burridge brett@babylon6.demon.co.uk        --
   --support available from http://www.babylon6.demon.co.uk      --
   --For this script to work you need AREXX to be running,       --
   --the commands RUN and EXECUTE in c:, and the WhirlGIF        --
   --executable to also be in c:                                 --
   --WhirlGIF source code is available from                      --
   --http://www.msg.net/utility/whirlgif                         --
   ----------------------------------------------------------------

*/
options results

/* Select the files to use as animation frames */

REQUEST_MULTIFILE PATTERN "#?.gif" TITLE '"Select GIF files to use as animation frames:"' STEM inputfiles.

do l = 0 to (inputfiles.files.count - 1)
Open(brett2,'ram:framelist.txt','W')
writeln(brett2, ''||inputfiles.files.l||'')
close (brett2)
end

/* Get outputfile */

REQUEST_FILE TITLE '"Enter filename to save the animation as:"' STEM outputfile.

/* Make sure we don't overwrite anything of value! */

outfile = outputfile.file

IF EXISTS(outfile) then do

REQUEST_MESSAGE TEXT '"This file already exists. Overwrite it?"' BUTTONTEXT "Yes|No"

over1 = result

 if result == 0 then do

  REQUEST_MESSAGE TEXT '"Sorry, you will have to run the script again :-("'
 exit
 end

else if over1 == 1 then do

end

end

/* Do you want a looping animation? */

REQUEST_STRING TITLE '"Enter looping information"' TEXT1 '"Enter the number of loops"' TEXT2 '"for the animation"' TEXT3 '"0 = loop forever"'

loop = result

/* How much time between frames */

REQUEST_STRING TITLE '"Enter timing information"' TEXT1 '"Enter timing between frames"' TEXT2 '"(1 = fast 50 = one second)"' TEXT3 '"A time of 0 is not advised!"'

timing = result

/* What disposal effect is required? */

REQUEST_MESSAGE TITLE '"Enter disposal information"' TEXT '"What disposal effect do you require?"' BUTTONTEXT "None|Not|Background|Previous"

disp1 = result
disposal = ''
    if disp1 == 1 then disposal = 'none'
     else if disp1 == 2 then disposal = 'not'
     else if disp1 == 3 then disposal = 'back'
     else if disp1 == 0 then disposal = 'prev'

/* What palette entry for the transparent colour? */

REQUEST_MESSAGE TITLE '"Select transparency effect"' TEXT '"Do you wish to specify a certain colour as transparent?"' BUTTONTEXT "Yes|No"

trans1 = result
   if trans1 == 1 then do

REQUEST_STRING TITLE '"Enter palette information"' TEXT1 '"Enter palette colour number"' TEXT2 '"corresponding to transparent colour"'
trans = '-trans '
trans2 = result
trans = trans||trans2
end

else if trans1 == 0 then do

trans = ''

end


/* Save the WhirlGIF command line */

Open(brett1,'ram:whirlgifcommandline.txt','W')
writeln(brett1,'run > NIL: c:whirlgif '||trans||' -disp '||disposal||' -time '||timing||' -o '||outputfile.file||' -loop '||loop||' -i ram:framelist.txt')
Close(brett1)

/* Let's get the show on the road */

address command 'execute ram:whirlgifcommandline.txt'


exit
