#! /bin/csh -f
#Tag 0x00ff0408

if(`printenv SW_BASE` == "") setenv SW_BASE /usr/local/softWoRx
if(`uname -s` == "Linux") then
	set TARG=`uname -p`
else
	set TARG=mips
endif

#echo Base=$SW_BASE Targ=$TARG
setenv LD_LIBRARY_PATH $SW_BASE/lib

$SW_BASE/bin/$TARG/ViewFile "$1" -NoMenu

# If a status of 2 is returned, DV isn't running. Start it.
if($status == 2) then
    set pids_file=/tmp/.softWoRx_PIDS_$LOGNAME
    
    set counter=0
    $SW_BASE/bin/$TARG/DV &
    
    while(!(-e $pids_file) && $counter < 25)
        echo looking for $pids_file
        sleep 1
        @ counter++
    end
    
    if ($counter < 15 && (-e $pids_file)) then
        $SW_BASE/bin/$TARG/ViewFile "$1" -NoMenu
    endif
endif
