/*
** Grab.rexx
**
** $VER: Grab.rexx 2.0.0 (25.01.78)
**
** ARexx script generated by T-Rexx Professional 2.0.1
*/

signal on SYNTAX
signal on BREAK_C
signal on HALT

options failat 200

Switcher = 'ToasterARexx.port'	/* address Switcher's ARexx port */

if ~show('L','rexxsupport.library') then
	call addlib('rexxsupport.library',0,-30)
if ~show('L',Switcher) then
	call addlib(Switcher,-1)

say pragma('directory',"DH0:Toaster/")

if ~show(port,Switcher)				/* if the Switcher is not around, */
then								/* then start it up. */
	do
	if EXISTS('Switcher') then
	do
		say 'Starting up the Toaster Switcher...'
		address command 'Run >NIL: <NIL: Switcher'
		address command 'WaitForPort ToasterARexx.port'
		if ~show(port,Switcher) then
		do
			say 'Could not start the Switcher'
			exit -1
		end
	end
	else
	do
		say "Can't find Switcher, check TOASTER setting"
		DELAY(150)
		exit -1
	end
end

TS=show(port,Switcher)

say 'Begining execution...'

Begin:

Trap = Switcher(TOSW)
Trap = Switcher(FVID)
Trap = Switcher(TOWB)
address Helm.1 screentofront

/*  End of the command list  */

say 'Exiting...'
exit 0

halt:
syntax:
	ERC=RC
	OPEN(ErrorOut,'RAM:T-Rexx.errors','W')
	ERR=SIGL-52
	WRITELN(ErrorOut,ERR' - Error in script -' SourceLine(SIGL))
	CLOSE(ErrorOut)
	if TS then Switcher(TOWB)
	address command 'type RAM:T-Rexx.errors'
	DELAY(125)
	exit 10

break_c:
	if TS then Switcher(TOWB)
	say 'Execution halted by Ctrl-C'
exit 10


TDelay:
arg hours, minutes, seconds, frames

	total=0

	if hours > 0 then total=(hours * 60 * 60 * 50)
	if minutes > 0 then total=total + (minutes * 60 * 50)
	if seconds > 0 then total=total + (seconds * 50)
	if frames > 0 then total=total + ((frames + 1) / 50 * 100)
	if total > 50 then total=total % 1
	if minutes > 0 then total=total - (100 * minutes)

	do while total >= 50
		say '08'x
		Delay(50)
		total=total-50
	end

	if total > 0 then Delay(total)
return 0
