/* Figlet.ged by Troels Walsted Hansen
** $VER: Figlet.ged v1.00 (09.06.95)
**
** An ARexx script that asks you for a string and a figlet font,
** and then, using the figlet program, writes whatever string you
** entered, in the font you chose, into the editor.
*/

/* some user variables. edit to your hearts content */

figletprogpath = "Work:Verktøy/TextUtils/Figlet/"
figletfontpath = "Work:Verktøy/TextUtils/Figlet/"

/* needs GoldED functions */

options results

if(substr(address(),1,6) ~= "GOLDED") then
do
	say "This script should only be started from inside GoldED."
	exit 20
end
else gedport = address()

/* get string */

address(gedport)
REQUEST BODY '"Enter some text:"' BUTTON '"_Ok|_Cancel"' TITLE '"Figlet.ged"' VAR figletstring STRING
if(rc ~= 0) then exit

/* get fontname */

REQUEST TITLE '"Select figlet font:"' FILE PATH '"'figletfontpath'"' MASK '"#?.flf"' VAR figletfont
if(rc ~= 0) then exit

lastchar = right(figletfont,3)
if(lastchar ~= "flf" | figletfont = "") then exit

/* run figlet */

call open(ofh, "T:figlet.fse.temp.file1", W)
	call writeln(ofh, figletstring)
call close(ofh)

QUERY RIGHT VAR columnsnumber

address command
figletprogpath || 'figlet <T:figlet.fse.temp.file1 >T:figlet.fse.temp.file2 ' || delstr(figletfont, lastpos(".",figletfont)) || ' center columns ' || columnsnumber

address(gedport)
OPEN NAME '"T:figlet.fse.temp.file2"' FAST INSERT

/* cleanup and exit */

if(exists("T:figlet.fse.temp.file1")) then address command 'delete >nil: "T:figlet.fse.temp.file1"'
if(exists("T:figlet.fse.temp.file2")) then address command 'delete >nil: "T:figlet.fse.temp.file2"'
exit
