/* ASCIIPic.fse by Troels Walsted Hansen
** $VER: ASCIIPic.fse v1.02 (03.12.94)
**
** Convert picture to ASCII and include it in the FSE. Uses
** 'ilbm2ascii' v1.4 by Tobias Ferber.
*/

defpath = 'work:pictures/'		/* Edit to suit your environment */

options results

/* needs THOR and FSE functions */

if(substr(address(),1,8) ~= "THOR_FSE") then
do
	say "This script should only be started from inside the FSE."
	exit 20
end
else fseport = address()

p = address() || ' ' || show('P',,)
thorport = pos('THOR.',p)

if thorport > 0 then thorport = word(substr(p,thorport),1)
else
do
	say 'No THOR port found!'
	exit 10
end

address(thorport)

REQUESTFILE TITLE '"Select ILBM to convert and include:"' ID '"'defpath'"' FP PAT '"#?"'
if(rc ~= 0) then exit
else picfile = result

lastchar = right(picfile,1)
if(rc~=0|lastchar = "/"|lastchar = ":"|picfile = "") then exit

address command "ilbm2ascii "||'"'picfile'"'||" > t:FSEASCIIPicture"

address(fseport)
INCLUDEFILE 't:FSEASCIIPicture'

address command "delete >nil: t:FSEASCIIPicture"

exit
