/* Batch Convert to Ww v1.0, for Wordworth v4SE by Ryan Morse © 1996.
$VER: Batch_Convert_to_Ww_Macro v1.0 (7/2/96)

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

INSTRUCTIONS: This macro will batch convert all selected files to the Wordworth file format. You can choose the files at the start of the macro and Wordworth will do the rest, freeing you to do other work. THIS macro WILL NOT OVERWRITE YOUR ORIGINAL FILE, BUT WILL ADD A SUFFIX. This macro is forward compatible, and, if used in a new version of Wordworth, will support any future enhancements to the file format. This macro should also support any Wordworth file formats (Word Perfect, etc.) for loading.

NOTE: The FITWIDTH command has been added in case you have adjusted your display mode or changed the layout of the Wordworth screen.

NOTE: When selecting plenty of files, you may forget what the last file you selected was. Just check the File: text gadget in the File requester. Also, to avoid mistakes, either start at the bottom of a directory and work your way up or vice-versa.

NOTE: This macro works by using an array to store file names as records. These are numbered, so that the file names can not be over written. The macro then resets the database to the first record, for Wordworth to load and convert each file (as they appear in the database) in succession. */

/* Notify user */
REQUESTRESPONSE 'This macro will convert ALL user selected documents to Wordworth.'
/* If user cancels requester then stop macro */
IF RC>0 THEN DO
	REQUESTNOTIFY 'AREXX MACRO CANCELLED.'
	EXIT
	END

/* RETURN RESULTS */
/* This will allow Wordworth to obtain the file names */
OPTIONS RESULTS

/* CREATE WORK AREA */
NEW PORTNAME ConvertWorkArea
/* Address work area */
ADDRESS ConvertWorkArea

/* CREATE NECESSARY VARIABLES */
/* Create variable for file selection */
Number = 1
/* Create variable for convert loop */
Amount = 0
/* The amount is set to zero because no records have been created yet */

/* CREATE LOOP FOR FILE SELECTION */
/* Notify user */
REQUESTNOTIFY 'To convert selected files, CANCEL the file requester.'
/* Continue loop until user cancels file requester */
DO FOREVER

	/* SELECT FILES */
	/* Select documents to convert */
	REQUESTFILE TITLE 'Select file' Number 'to CONVERT...'
	/* If user cancels requester then start convert loop */
	IF RC>0 THEN DO

			/* CONVERT SELECTED FILES */
			/* Notify user */
			REQUESTRESPONSE 'CONVERT' Amount 'SELECTED FILES TO  WORDWORTH?'
			/* If user cancels requester then stop macro and close work area */
			IF RC>0 THEN DO
				REQUESTNOTIFY 'AREXX MACRO CANCELLED.'
				CLOSE FORCE
				EXIT
				END
			/* Reset value of Number to load files */
			Number = 1
			/* Start convert loop */
			DO Amount
				/* Open document */
				OPEN FILENAME File.Number FORCE
				/* The FORCE command suppreses the 'Save changes?' requester */
				/* Adjust layout */
				FITWIDTH
				/* Convert document */
				SAVEAS NAME File.Number || '.Ww'
				/* Change value of Number to open and convert next record */
				Number = Number + 1
				/* Stop convert loop when all records have been converted */
				IF Number > Amount THEN DO
					/* Notify user */
					REQUESTNOTIFY 'CONVERSION TO WORDWORTH HAS FINISHED.'
					/* Close work area */
					CLOSE FORCE
					/* Stop macro */
					EXIT
					END
				/* End of Do loop for convert */
				END

		/* End of Do loop for requester */
		END

	/* CREATE ARRAY USING NUMBERED FILE NAMES AS RECORDS */
	/* Create value for result and number it */
	File.Number = RESULT
	/* Change value of Number to create other records */
	Number = Number + 1
	/* Record amount of records for convert loop */
	Amount = Amount + 1
	END
