#!/bin/sh
#	$RCSfile: kea-load.sh,v $ $Revision: 1.1 $
# kea-load.sh                   Download KEAterm Macro files to PC
# ================================================================
# This unix script will download the KEAterm Macro files needed to
# run the KEAterm interface to APPX.  Before running, this script
# checks for all of the environment variables needed to run the
# interface.  Any ERRORs must be corrected before the APPX/KEAterm
# interface will run.  Once the variables have been EXPORTed and
# the MACRO files downloaded, you may run APPX using KEAterm and
# the APPX/KEAterm interface will be active.
# ================================================================

echo ""
grep "^# " ./kea-load.sh
echo ""

if [ -z "$APPX_KEATERM" ]
then
	echo "ERROR! APPX_KEATERM Variable not set!"
	echo "       Please 'export APPX_KEATERM=buttons'"
	echo ""
	ERRORFLAG="yes"
fi

if [ "$APPX_KEYMAP" != "keaterm" ]
then
	echo "ERROR! APPX_KEYMAP Variable not set to 'keaterm'!"
	echo "       Please 'export APPX_KEYMAP=keaterm'"
	echo ""
	ERRORFLAG="yes"
fi

if [ -z "$APPXPATH" ]
then
	echo "ERROR! APPXPATH Variable not set!"
	echo "       Please 'export APPXPATH={your APPX data path}'"
	echo ""
	ERRORFLAG="yes"
fi

if [ -n "$ERRORFLAG" ]
then
	exit
fi

echo "Loading MACRO Files from ../keaterm to your PC directory...."
echo "\033P4.z"
echo "TransferReceive(Options=Xfer_Kermit+Xfer_Overwrite)"
echo "ApxMap()"
echo "Save()"
echo "\033\\"
./kermit -s ../keaterm/*.ktm
echo "Load Complete!"


