#!/bin/bash

FILE=$1

if [ -z "$FILE" ]
then
	printf "\nusage: $0 [filename]\n\n"
	exit 1
fi

#remove existing file
rm -f ${FILE}.hpprgm

#get it
printf "6\n$FILE\nprgm\n0\n" | $(dirname $0)/test_hpcalcs.sh

#if we got it, then convert it
if [ ! -r "${FILE}.hpprgm" ]
then
	printf "\nerror: cannot read ${FILE}.hpprgm, get failed!\n\n"
	exit 1
fi

$(dirname $0)/iconv -f UTF-16LE -t UTF-8 ${FILE}.hpprgm >${FILE}.ppl

