#!/bin/bash

#©keithhedger Sat 8 Oct 13:26:24 BST 2016 kdhedger68713@gmail.com
KKEDIT=../../app/kkedit
KKMSG=../../app/kkeditmsg
INSTANCE=12345999

#if arg then remove and flush q then exit
if [ "X$1" != "X" ];then
	$KKMSG -k $INSTANCE -fR
	exit 0
fi
#make sure queue is empty
$KKMSG -k $INSTANCE -f

#open instance or bring to front
($KKEDIT -i $INSTANCE) &

#tell instance to inform us after loading has finished
$KKMSG -k $INSTANCE -s "WaitForKKEdit" -a
#open files
$KKEDIT -i $INSTANCE /etc/fstab /etc/hosts
#block until finished loading
$KKMSG -k $INSTANCE -b


$KKMSG -k $INSTANCE -s "PrintFiles" -a
#wait for 1st message then print all meassages to stdout
$KKMSG -k $INSTANCE -r

#wait for user ( click Navigation->Continue )
$KKMSG -k $INSTANCE -s "ShowContinue" -a
#block until user continues
$KKMSG -k $INSTANCE -b
#print list of open files
$KKMSG -k $INSTANCE -s "PrintFiles" -a
#print all meassages to stdout
$KKMSG -k $INSTANCE -r

#send quit
$KKMSG -k $INSTANCE -s "Quit" -a
#flush and remove queue
$KKMSG -k $INSTANCE -fR


