/* Amiga Guide Convert for WB2 v1.0, for Wordworth v5 by Ryan Morse.
$VER: AmigaGuide_Convert_for_WB2 1.0 (10/1/96)

This script will convert a Workbench 3 Amiga Guide document for Workbench 2.

This script works by finding commands that are incompatible with WB 2, and removes them. This is useful for users who have used Wordworth to create a guide file (using features such as Wordwrap), and want to create another version for WB 2 users.

NOTE:  A template "Amiga_Guide_OS2" has been provided for WB 2 authors, which also provides a link to an Index page to compensate for the lack of support for the Index node.

USAGE:  Write or update the WB 3 guide, and save it using the "AG_Save_Docs" ARexx script, and then run this script to convert the guide and save a new guide for WB 2 users.

I only have a WB 3 machine and am not sure what features have to be deleted for WB 2 users. I have, however, looked at programmes which perform a similar function as this script, and these delete the following: WORDWRAP node, INDEX node, FONT node. Some of these programs also delete styles, although this is not necessary. I have included a feature to delete these styles, (except for highlight styles). I have based this script on "AGuideConv" by Michael Friedrich (v1.0 © 1994).

This script is very similar to "AGuideConv" in that it: 1) operates on the file in memory (you are working on the file in Wordworth), 2) it uses a set text width (please refer to the WB 2 Amiga Guides notes in the Wordworth PD guide), BUT 3) it allows the user to save the file under a different name. 

NOTE:  The longer your document is, the longer this script will take to work... But, unlike other programs, YOU CAN CONFIGURE THIS SCRIPT TO SUIT YOUR NEEDS. */

/* Notify user */
REQUESTRESPONSE 'This script will convert the current Amiga Guide for WB 2.'
/* If user cancels requester then stop script */
IF RC>0 THEN DO
	REQUESTNOTIFY 'AREXX MACRO CANCELLED.'
	EXIT
	END

/* DELETE ALL WB 2 INCOMPATIBLE NODES */
/* Find and delete Wordwrap node */
POSITION SOF
FINDCHANGE FIND '@WORDWRAP' CHANGE ''
/* Select and delete whole line */
POSITION SOL
/* Select line */
SHIFTDOWN; CURSOR DOWN SHIFTDOWN
/* Notify user */
REQUESTRESPONSE 'Deleted WORDWRAP command. Delete rest of line?'
IF RC=0 THEN DO
	CUT
	END

/* Find and delete Index node */
POSITION SOF
FINDCHANGE FIND '@INDEX' CHANGE
/* Select and delete whole line */
POSITION SOL
/* Select line */
SHIFTDOWN; CURSOR DOWN SHIFTDOWN
/* Notify user */
REQUESTRESPONSE 'Deleted INDEX command. Delete rest of line?'
IF RC=0 THEN DO
	CUT
	END

/* Find and delete Font node */
POSITION SOF
FINDCHANGE FIND '@FONT' CHANGE ''
/* Select and delete whole line */
POSITION SOL
/* Select line */
SHIFTDOWN; CURSOR DOWN SHIFTDOWN
/* Notify user */
REQUESTRESPONSE 'Deleted FONT command. Delete rest of line?'
IF RC=0 THEN DO
	CUT
	END

/* DELETE ALL STYLES */
/* Notify user */
REQUESTRESPONSE 'All WB 2 incompatible codes have been deleted. Delete all styles?'
/* If user cancels requester then stop script */
IF RC>0 THEN DO
	REQUESTNOTIFY 'No styles deleted. SAVE the WB 2 guide.'
	/* SAVE WB 2 GUIDE */
	/* The SAVEAS command will produce a requester to rename the guide */
	SAVEAS ASCII
	EXIT
	END

/* DELETE ALL STYLES */
/* Find and delete all ITALIC style codes */
REQUESTNOTIFY 'Deleting all Italic styles.'
POSITION SOF
FINDCHANGE ALL FIND '@{i}' CHANGE ''
/* Find and delete all END of ITALIC style codes */
POSITION SOF
FINDCHANGE ALL FIND '@{ui}' CHANGE ''

/* Find and delete all BOLD style codes */
REQUESTNOTIFY 'Deleting all Bold styles.'
POSITION SOF
FINDCHANGE ALL FIND '@{b}' CHANGE ''
/* Find and delete all END of BOLD style codes */
POSITION SOF
FINDCHANGE ALL FIND '@{ub}' CHANGE ''

/* Find and delete all UNDERLINE style codes */
REQUESTNOTIFY 'Deleting all Underline styles.'
POSITION SOF
FINDCHANGE ALL FIND '@{u}' CHANGE ''
/* Find and delete all END of UNDERLINE style codes */
POSITION SOF
FINDCHANGE ALL FIND '@{uu}' CHANGE ''

/* Notify user of changes */
REQUESTNOTIFY 'All styles have been deleted, now SAVE the WB 2 guide.'

/* SAVE WB 2 GUIDE */
/* The SAVEAS command will produce a requester to rename the guide */
SAVEAS ASCII
