# File sample/psql.rb, line 566
def setFout(ps, fname)
  if (ps.queryFout && ps.queryFout != STDOUT)
    ps.queryFout.close
  end

  if !fname
    ps.queryFout = STDOUT
  else
    begin 
      if fname[0, 1] == "|"
        dumy, ps.queryFout = pipe(fname)
        ps.pipe = TRUE
      else
        ps.queryFout = File.new(fname, "w+")
        ps.pipe = FALSE
      end
    rescue
      ps.queryFout = STDOUT
      ps.pipe = FALSE
    end
  end
end