/* Picture Process GL24 v1.0, for Wordworth v5 by Ryan Morse.
$VER: Picture_Process_GL24_Macro version (16/06/96)

This macro is part of the DrawPlus (© Ryan Morse) Wordworth ARexx enhancement set.

INSTRUCTIONS: Just select an image file and click on an option. The rotate feature in this script requires GFXLAB 24. */

/* Return results */
OPTIONS RESULTS

/* Notify user */
REQUESTRESPONSE 'This script will allow you to process an image. Rotate requires GFXLAB 24.'
/* If user cancels requester then stop script */
IF RC>0 THEN DO
	REQUESTNOTIFY 'AREXX MACRO CANCELLED.'
	EXIT
	END

FILEREQUESTER:
/* Request image to process */
REQUESTFILE TITLE 'Process image...'
PictureFile = RESULT
SaveFile = PictureFile
/* If user cancels requester then stop script */
IF RC>0 THEN DO
	REQUESTNOTIFY 'AREXX MACRO CANCELLED.'
	EXIT
	END

CONTROLPANEL:
WIZARDREQ TITLE 'Picture Process, by Ryan Morse © 1996' LABEL 'Click on appropriate button to process the image.' LABEL 'To rotate an image you need Gfx Lab 24.' LABEL 'Enter the rotation angle and Save File below:' TEXTBOX 1 '_Load:' CONTENTS SaveFile TEXTBOX 2 'Pr_eview:' CONTENTS 'C:PPShow' TEXTBOX 3 '_Angle:' TEXTBOX 4 '_Save File:' CONTENTS SaveFile BUTTON 1 '_Place' BUTTON 2 'P_review' BUTTON 3 'R_otate' BUTTON 4 '_New' BUTTON '-1' '_Cancel'

/* BUTTONS */
/* Create variable for result of button */
ButtonResult = RESULT
/* Cancel button */
IF ButtonResult = -1 THEN DO
	REQUESTNOTIFY 'AREXX MACRO CANCELLED.'
	EXIT
	END

/* GET TEXTBOX RESULTS */
/* Load file */
WIZARD_GETTEXTBOX 1
LoadFile = RESULT
/* Preview file */
WIZARD_GETTEXTBOX 2
PreviewProgram = RESULT

/* Place button */
IF ButtonResult = 1 THEN DO
/* NOTE: Wordworth does not accept a filename option on the Place Picture command, so you will have to select the file again. I have left in the LoadFile variable in case Digita adds a filename option in a future revision of Wordworth. */
	PLACEPICTURE LoadFile
	EXIT
	END

/* Preview button */
IF ButtonResult = 2 THEN DO
	/* Run preview program */
	ADDRESS COMMAND PreviewProgram '"' || LoadFile || '"'
	SIGNAL CONTROLPANEL
	END

/* Rotate button */
IF ButtonResult = 3 THEN DO

	/* GET TEXTBOX RESULTS */
	/* Angle */
	WIZARD_GETTEXTBOX 3
	Degree = RESULT
	/* Save File */
	WIZARD_GETTEXTBOX 4
	SaveFile = RESULT

	/* Error trapping */
	IF Degree < '0' | Degree > '359' THEN DO
		/* Notify user */
		REQUESTNOTIFY 'The Angle must come between 0 and 359 degrees inclusive.'
		SIGNAL CONTROLPANEL
		END

	/* OPEN GFX LAB 24 */
	/* If Gfx Lab 24  port is not open then run Gfx Lab 24  */
	IF ~SHOW('p',"GFXLAB.1") THEN DO
		ADDRESS COMMAND 'run GfxLab24:GfxLab24'
		REQUESTNOTIFY 'Send Wordworth to back and check that GFXLAB 24 IS running.'
		/* Wait for Gfx Lab 24 port to open */
		ADDRESS COMMAND 'WaitForPort' GFXLAB24.0
		END
	/* Address GFX LAB 24 */
	ADDRESS GFXLAB24.0
	/* Notify user */
	PRINTINFO 'Rotate image for Wordworth by Ryan Morse.'

	/* LOAD IMAGE */
	/* Notify user */
	PRINTINFO 'Loading image:' LoadFile
	/* Load image */
	LOAD '"' || LoadFile || '"' BANK 1

	/* GET PICTURE SIZE FOR ROTATION */
	/* Notify user */
	PRINTINFO 'Getting image dimensions for rotate.'
	/* Get dimensions */
	GETHEIGHT BANK 1
	Height = RESULT
	GETWIDTH BANK 1
	Width = RESULT

	/* ROTATE IMAGE */
	/* Notify user */
	PRINTINFO 'Rotating image.'
	/* Rotate image */
	ROTATE 100 100 Degree FULLPICTURE BANK 1

	/* SAVE IMAGE */
	/* Notify user */
	PRINTINFO 'Saving image:' SaveFile
	/* Save image */
	SAVE '"' || SaveFile || '"' BANK 1

	/* QUIT GFX LAB 24 */
	/* QUIT */
	/* Address Wordworth */
	ADDRESS WORDWORTH.1
	/* Go back to control panel */
	SIGNAL CONTROLPANEL
	END

/* New button */
IF ButtonResult = 4 THEN DO
	SIGNAL FILEREQUESTER
	END
