#!/bin/csh
#     Copyright (C) 2017 Jiabo Li, Brian Duke, and Roy McWeeny
# 
#     This program is free software: you can redistribute it and/or modify
#     it under the terms of the GNU General Public License as published by
#     the Free Software Foundation, either version 3 of the License, or
#     (at your option) any later version.
# 
#     This program is distributed in the hope that it will be useful,
#     but WITHOUT ANY WARRANTY; without even the implied warranty of
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#     GNU General Public License for more details.
# 
#     You should have received a copy of the GNU General Public License
#     along with this program.  If not, see
#     <https://www.gnu.org/licenses/>.
###########################################################################
#
#   You need to set the VBFILE variable below.
#
# Where my VB2000 directory is:-
setenv VBFILE $HOME/vb2000
#
# Where my GAMESS vb2000 directory is:-
#setenv VBFILE $HOME/gamess/vb2000
#
#echo $VBFILE
#
#   This is VB2000 help utility, modelled on gmshelp the GAMESS
#   Unix on-line help - written by Greg Atchity, 25 March 1993.
#
#   This script makes it simple to display the VB2000 input keywords
#   from a text version of part of the VB2000 manual, in the spirit of 
#   the Unix 'man' command.
#   Plain text, quickly displayed, and just as quickly exited.
#
#   This script should be made available to all users, which is very easy:
#      a) make sure that VB-help-file is world readable:-
#         chmod 644 VB-help-file
#      b) change the 'doc' variable to point to your site's actual file name
#      c) make it available, e.g. 'alias vbhelp /full/path/to/vbhelp',
#         or copy it to a location such as /usr/local/bin on people's path.
#
#   Note that the little known "b" subcommand to 'more' will allow you
#   to read backwards, just as a "space bar" lets you read forward.  The
#   only  other 'more' subcommand you need to know is "q" for quit!
#
set doc=$VBFILE/DOC/VB-help-file
#echo $doc

if ($1 == '-h' | $1 == '-H') then
  set me=$0
  echo Usage: $0 \[command-name\]
  echo " "
  echo Typing just \"vbhelp\" will give you access to the part of 
  echo the manual that described the input in general terms
  echo " "
  echo Typing \"vbhelp name\" will give information about
  echo the name command, e.g. \"vbhelp GRPDIM\"
  echo " "
  echo Don\'t include the dollar sign in the namelist group.
  echo " "
  echo $me:t uses the pager "'more'" by default but will work with "'pg'"
  echo or "'less'" by putting one of those pagers in your PAGER environment
  echo variable.
  echo " "
  echo You can not type in a comand-name that starts with "##" such as
  echo \#\#VBSTR. Use 01VBSTR instead.
  exit 0
  echo " "
endif

if ($?PAGER) then
   set pager=$PAGER
else
   set pager=more
endif

#--set key=`echo $1 | tr "[a-z]" "[A-Z]"`  # English-centric case ranges

if ($#argv == 0) then
   $pager $doc
else
   set key=`echo $1 | tr '[:lower:]' '[:upper:]'`
   set key2=`echo $key | sed "s/[0-9][0-9]/##/g"`
   $pager "+/^.*$key2" $doc
endif
