#!perllocation
#
# getfile1vars
#  this utility does much the same work as build-opt-env.pl
#    in manipulating the object, but in this case, the object
#    is not available in the environment
#
# calling routine includes build-opt-env.pl
#  with a do 'build-opt-env.pl';
#
do 'build-opt-env.pl';
$mainlocation = "$ENV{'USETEMPDIR'}"."/";
#
# open the file JGTEMP/port_no/remote_host/join-object-1
#
$objnamefile="$mainlocation"."join-object-1";
open(OBJ,"$objnamefile") || die "Cannot open object $!<p>\n";
  while (<OBJ>) {
    $object1 = $_;
  }
chomp($object1);
close(OBJ);
$dispobj=$object1;

#print STDERR $object1," at 1\n";
#
# remove file extension from object 1 - anything beyond final '.'
#

if (rindex($object1,".") > rindex($object1,"/")) {
   $dispobj=substr($object1,0,rindex($object1,"."));
}
#
# open the file USETEMPDIR/parameters, containing
#    the subselections active, if any, for object 1
#    Note that we are 'positive reporting' here, expecting
#    to see 'none' if there are no subselections active.
#    See '/jg/putjoinenv' for code to create these files
#
$paramfile="$mainlocation"."parameters";
open(IN,"$paramfile") || die "Cannot open parameters $!<p>\n";
   while (<IN>) {
     $param1 = $_;
   }
  chomp($param1);
  close(IN);

#print STDERR "at 2: ",$param1,"\n";

  if ($param1 ne "none") {
    if ($param1 =~ /[&;]/) {
       $subsels=`$topdir/bin/htmlunesc "$param1"`;
    } else {
       $subsels = "$param1";
    }

    if ($subsels =~ /[<>]/) {
       $dispss=`$topdir/bin/htmlesc "$subsels"`;
    } else {
       $dispss="$param1";
    }

    $dispss=`$topdir/bin/trigram_util -un "$dispss"`;
  }
#
#  open the file USETEMPDIR/from_loc, containing
#    the referring URL, probably optserv1's Plotting and OO menu
#
$from_location="$mainlocation"."from_loc";
open(IN,"$from_location") || die "Cannot open fromlocation $!<p>\n";
  while (<IN>) {
    $refloc = $_;
  }
close(IN);
chomp($refloc);

