/* Batch Convert to PC v1.0, for Wordworth v5 by Ryan Morse © 1996.
$VER: Batch_Convert_to_PC_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 Word Perfect file format on the PC. 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. If, however, you would like to overwrite the original file, then change the SAVEAS NAME command in this macro.

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 PC.'
/* 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 PC?'
			/* 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 */
				/* Convert document */
				/* The suffix .PCT stands for PC Transfer */
				SAVEAS WORDPERFECT NAME File.Number || '.PCT'
				/* 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 PC 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
