#!/bin/csh -f

if ( ! $?OS ) set OS=unknown

if ( $OS == "Windows_NT" ) then
    set UI_COMPILE = $HFS/bin/uicompile.exe
else
    set UI_COMPILE = $HFS/houdini/sbin/uicompile
endif

if ( ! -x $UI_COMPILE ) then
    echo "$UI_COMPILE not found."
    exit 1
endif

if( ! $?TEMP ) set TEMP=/tmp

set tmp=$TEMP/ui$$
onintr cleanup
set status=0
foreach f ( $* )
    if ( ! -f $f ) then
	echo "${0}: UI file $f not found."
	set status=1
    endif

    $UI_COMPILE $f >$tmp 
    if ( $status == 0 ) then
	mv -f $f ${f}.old
	if ( $status == 0 ) then
	    mv $tmp $f
	    echo $f converted.
	endif
    else
	echo "${0}: Error: $f compile failed."
    endif
end

cleanup:
rm -f $tmp
exit $status
