# showtime - A scrolling ad with interstellar cliches.	This was inspired
# by the script marquis.rexx, although it has almost nothing in common except
# for the scrolling effect.
#
# Showtime is presented as is; no warrantee is either expressed or implied
# as to it's suitability to any purpose whatsoever.  You assume all the
# risk for all damage, even if caused by a defect in the software,
# no matter how awful.

local msgs i j k n m2 msg hdr p1 w t1=ran(48) hh=t1/2 mm=(t1%2)*30 ttl o IFS window_name
t1=(hh+2)%24, IFS="\n"

set msgs `cat << +`
I'm a doctor, not a bricklayer!
I'm a doctor, not a mechanic!
I'm a doctor, not an engineer!
I'm a doctor, not an escalator!
He's Dead, Jim.
Bones, there's a Thing out there
REALLY, Doctor!
Beam me up, Scotty
Sensors indicate no intelligent life
I have a BAD feeling about this
It's our only hope
May the Force be with you
Phasers, on stun
+

if mm==0
   mm="00"
endif
if ?argv[1]
    if ?_title
	ttl=_title
    else
	ttl=0
    endif
    _title="Amiga Tunes daily at $hh:$mm and $t1:$mm"
    o=1,w=width
else
    window_name="con:0/0/640/54/Amiga Tunes daily at $hh:$mm and $t1:$mm"
    c:version version 36 >NIL:
    if status == 0
	window_name=cat(window_name,"/nosize")
    endif
    o=open(window_name,"w")
    if o==0
	o=1,w=width
    else
	w=77
    endif
endif

onintr goto finis; onerr goto finis
# clear the screen
echo -n "\f" >&$o
msg="bsh -- the interstellar shell!    ",hdr="Where no Amiga has gone before"

# center top message
p1=(w-strlen(hdr))/2
echo -n "\e[1;${p1}H\e[4m$hdr\e[0m" >&$o
# center bottom  message
n=ran(#msgs), m2=msgs[n], p1=(w-1-strlen(m2))/2
echo -n "\e[5;${p1}H\"$m2\"" >&$o
# turn cursor off for speed & a more pleasing display
echo -n "\e[0 p" >&$o
k=0, j=strlen(msg), p1=w-2
while k++ < 6
    i=1
    repeat j 'n=substr(msg,i++,1);echo -n "\e[3;4H\e[P\e[3;${p1}H$n" >&$o;sleep .1'
endwhile

label finis
onintr ""
if o > 2		# using our own custom window ?
    # allow a short period for admiration of window before closing it (1/2 sec)
    sleep .5
    close $o
else
    echo -n "\e[6;1H"	# position cursor past bottom message
    # turn cursor back on
    echo -n "\e[ p" >&$o
    if ttl
	_title=ttl
    else
	unset _title
    endif
endif
exit 0
