#------------------------------------------------------------------------------
# vlt.pl
# Functions to support automatic links to VLT on-line documents from WDB forms.
# 
# Author :  Bo Frese Rasmussen [ST-ECF]   <bfrasmus@eso.org>
#------------------------------------------------------------------------------


sub findfiles {
    local( $file, $doc, $issue ) = @_;
    local( $ret ) = "";

    $file = &stripblanks( $file );
    $doc = &stripblanks( $doc );
    $issue = &stripblanks( $issue );

    if ( ! $file ) {
	return "N/A";
    }
    $issue .= ".0" if ( ! ($issue =~ /\./) );
    $filedir = $file . "_DIR";
    $subdir = "$doc/issue_$issue/text";
    print DEBUG "findfile $form{$filedir}/$subdir/Document.ps"
		if $debug;
    if (-r "$form{$filedir}/$subdir/Document.ps") {
	$ret .= "<a href=\"$form{$file}/$subdir/Document.ps\">"
		. "PS</a> ";
    }
    if (-r "$form{$filedir}/$subdir/html/Document.html") {
	$ret .="<a href=\"$form{$file}/$subdir/html/Document.htm
l\">"
		. "HTML</a> ";
    }
    if ( $ret ne "" ) {
	return $ret;
    }
    return "N/A ?";
}
sub stripblanks {
    local( $str ) = @_;
    local( $ret ) = $str =~ /^\s*((\s*[^\s]+)+)\s*$/;
    return $ret;
}


