/* showiff24IM.rexx shows an iff-24 file in ImageMaster */
/* when you select it in Directory Opus or if you run */
/* this program from a shell.                         */

/*
** The program with the Firecracker24 called "showiff24" doesn't work
** very well.  If you use the overlay mode, and try to show a file,
** everything is OK until you send "aoff" to turn off the Amiga overlay.
** The picture snaps smaller than the screen, a most annoying bug!
** This program fixes all that, provided you have ImageMaster.
** It uses ImageMaster to display iff24 files on the FC; a much better
** solution.
** May be run from Directory Opus by setting the gadget as "executable"
** and then in the command line: RX sys:rexxc/showiff24.rexx {f}
** Set: output window, run asynchronously, and no filename quote.
** This allows the selected IFF 24 file to become an Argument to the
** program.  It is then displayed on the FC24 after ImageMaster is opened.
** May also be run from the shell with the file as argument, or the
** program will prompt you.  If you run it from dopus w/o specifying
** (selecting) a file, then the program prompts you to input a filename
** in the dopus output window.
** (c) 1992 by Merrill Callaway
*/

OPTIONS RESULTS

PARSE ARG filepath filename

/*
** Running from a shell, then if no arg is supplied, we need
** to ask for the filename.
*/

IF filepath='' THEN DO
   SAY 'Enter path/filename.'
   PARSE PULL device':'filename
   j=1
   DO WHILE filename ~= ''
      PARSE VAR filename path.j'/'filename
      j=j+1
      END
   wholepath=''
   DO i=1 TO j-2
      wholepath=wholepath||path.i'/'
      END
   filepath=device':'wholepath
   n=j-1
   filename=path.n
   END

/*
** Running from Directory Opus if no filename is supplied
** we need to ask for one.
*/

IF filename='' THEN DO
   SAY 'Enter the filename.'
   PARSE PULL filename
   END

/* End section on omitted args. */

CALL Locate_ImageMaster

/* Display the image? */
IF RESULT = 1 THEN CALL MAKEIMAGE filepath filename
ELSE EXIT 20

Locate_ImageMaster:

IF ~SHOW('P','IM_Port') THEN DO
/*
** NOTE!
** Make sure to change the following to YOUR path
** and the program name of the Imagemaster you use!
** This version is meant to run Imagemaster Firecracker
** version on an A-3000 with '030 accelerator, hence the
** "fcf" suffix.  Refer to your Imagemaster manual to see
** the name of the program you're running!
*/
   ADDRESS COMMAND "RUN Work:Imagemaster/imfcf"
   ADDRESS COMMAND WAITFORPORT 'IM_Port'
   IF RC=0 THEN RETURN 1
   ELSE RETURN 0
   END
ELSE RETURN 1


/* Here is where we save the image to the FC Board */
MAKEIMAGE: PROCEDURE
/* pass along the names of the path, file */
PARSE ARG filepath filename
ADDRESS 'IM_Port'
imtofront
imagepath filepath
load filename

/* remove the Amiga overlay in a two monitor set-up */
ADDRESS COMMAND aoff

/*
** NOTE
** If you quit ImageMaster, after the image displays,
** the image will disappear.  To get it back, should you
** have exited IMaster, open a shell and put in the commands
** "aoff" followed by "bon" (without quotes) at the prompts.
** The image should come back on your monitor.
** This program was set up for those using two monitors and the
** overlay feature of the FC.  If you use a different config, you
** may have to change the code slightly to get the desired
** combination of FC display w/ or w/o the Amiga Display, too.
*/


EXIT 0

