#!/usr/bin/regina
/*
 A simple xmessage-type script - younie@debian.org 2001/01

 Example usage:
   - put it somewhere in your path and make sure it's executable

 $ at 1900
 at> tknot time to walk the dog
 at> ^D

 */

	lf		= '0a'x

	parse arg phrase
	opts = ''
	if abbrev(phrase,'-') then parse var phrase opts phrase
	if opts = '-h' | opts = '--help' then do
		say 'Usage: tknot [-t] string'
		say '  -t  - include time'
		exit 0
	end

	/* time? */
	if pos('t',opts) <> 0 then phrase = time()||lf||lf||phrase
	phrase = lf||phrase||lf

	/* if used from cron, DISPLAY probably isn't set */
	if value('DISPLAY',,'SYSTEM') = ''
		then call value 'DISPLAY',':0.0','SYSTEM'

    call RxFuncAdd 'TkLoadFuncs','rexxtk','TkLoadFuncs'
    if RxFuncErrmsg() <> '' then do
		say RxFuncErrmsg()
		exit 1
	end
    call TkLoadFuncs

	call TkWm 'title', '.', 'Tknot'
	b = TkButton('.b', '-text', 'QUIT','-rexx', 'QUIT')
	l = TkLabel('.l', '-text', phrase)
	call TkPack l, '-side',  'top'
	call TkPack b, '-side',  'top'

	do forever
		interpret 'call' TkWait()
	end

QUIT:
	exit 0
