Processing math: 100%

5 SOFTWARE SUPPORT GUIDE

 5.1 Release Contents
 5.2 Portability Issues
 5.3 Library Format
 5.4 The INCLUDE files
 5.5 Subprograms
 5.6 Rebuilding the System
 5.7 VAX/VMS Logical Names

This section is intended for support programmers and those interested in the internal workings of the HLP package. It is unlikely to interest application programmers or users.

5.1 Release Contents

The complete HLP system, for all platforms, is stored in a single VAX/VMS directory. The following files are included:

*.FOR Fortran source (machine-independent)
*.BAT various PC MS/DOS command procedures (PC only)
*.COM various VAX/VMS DCL command procedures
*.OPT various VAX/VMS link option files
*.MAR transfer vector for VMS shareable images
*.IND Fortran source (machine-independent)
*.VAX Fortran source (VAX/VMS etc)
*.PCM Fortran source (PC – Microsoft Fortran under MS/DOS)
*.SUN4 Fortran source (Sun SPARC etc)
*.EXE Utility programs – VAX executables
*.OLB VAX object module library
READ.ME General information
HLP.NEWS NEWS item for current release
*.TEX,*.TOC LATEX source for document
MAKEFILE. make file for Unix platforms
MK. mk script, which sets environment variables and runs make
HLIB. Unix shell script for running CREHLP
HLP_LINK*. Part of Unix link procedure.
VAX_TO_UNIX.USH Unix shell script which accepts the release.

5.2 Portability Issues

The bulk of the system is coded in ANSI-standard Fortran. The only VAX extensions used are the SGP/16-sanctioned INCLUDE, DO WHILE, DO ... END DO and names longer than 6 characters. Full ANSI-compliance would be achieved by including the INCLUDEd text, recoding all the DOs and stripping the prefix “HLP_” from external names.

Specific machine dependencies are as follows. Filenames are given in their uppercase VAX/VMS forms, but are always lowercase on the Unix platforms.

The VAX, Sun SPARCstation and DECstation versions of the HLP system are supported by the Starlink Project. Versions for other Unix platforms will be produced if and when they are needed and will also be Starlink-supported. The PC version is supported by the author.

5.3 Library Format

A help library file (as opposed to a help source file) consists of three regions:

(1)
The header region, a single record, gives the size of the file, in characters, as a decimal number in I12.12 format.
(2)
The index region, terminated by an empty record.
(3)
The data region, lines of help text interspersed with keyword records. The text region, and the whole file, are terminated by an empty record.

For a more detailed picture, it is best to look at an actual file, and one is listed below. It is the example help source file given in Section 3.1, translated into a help library with the HLIB procedure, and listed using the LSTHLP utility. The first column of the listing is the character address. All records are terminated with the chosen “EOS” character, conventionally the null CHAR(0).

The file begins with the header record, in this case giving the total length of the file as 1937 characters. The records at character 13, 67, … 348 are the index region of the file, terminated by the empty record at character 386. The records at character 387, 411, … 1912 are the data region of the file, terminated by the empty record at character 1936.

The various fields of each index record are separated by spaces. Each record begins with three pointers in I9.9 format. The first pointer indicates the position of the item in the data region of the file. The second pointer indicates the position of the next index entry down the branch of the help tree. The third pointer indicates the position of the next entry of the same level. In this simple library, which does not contain references to other libraries, the three pointers are followed by the level number and the keyword. Where the library refers to another, the name of the referred-to library, prefixed with an “@”, is included prior to the level number; an example of this is given later.

      0   000000001937
     13   000000387 000000067 000000386 0 PROGRAMMING_LANGUAGES
     67   000000686 000000110 000000110 1 Assemblers
    110   000000812 000000197 000000152 1 Compilers
    152   000001473 000000310 000000386 1 Interpreters
    197   000000955 000000237 000000237 2 Fortran
    237   000001223 000000276 000000276 2 PASCAL
    276   000001324 000000152 000000152 2 C
    310   000001572 000000348 000000348 2 BASIC
    348   000001709 000000386 000000386 2 Forth
    386
    387   0 PROGRAMMING_LANGUAGES
    411   Programming via front-panel switches, or by plugboards, is no longer
    480   in fashion.  Even macho programmers now resort to describing what the
    550   computer is to do in terms of text which is assembled or compiled into
    621   machine code, or which is interpreted and executed line by line.
    686   1 Assemblers
    699   One line of assembly language used to turn into one machine instruction,
    772   but these days you’re never quite sure.
    812   1 Compilers
    824   A compiler turns high-level code which is supposed to be machine-
    890   independent but isn’t into machine code which definitely isn’t .
    955   2 Fortran
    965   An archaic language, a fossil remnant of 1950s IBM machines.  Used
   1032   to excellent effect by hordes of programmers round the world.  Produces
   1104   more efficient code than anything except assembler.  Its imminent
   1170   demise has been announced annually since about 1963.
   1223   2 PASCAL
   1232   Used for teaching structured programming.  Comes in various toxic
   1298   vendor-specific flavours.
   1324   2 C
   1328   The most successful computer virus to date.  Great to write in.
   1392   Produces really impressive gibberish code.  Goes wrong in all sorts
   1460   of fun ways.
   1473   1 Interpreters
   1488   There’s nothing quite like changing a line of code and instantly
   1553   seeing the result.
   1572   2 BASIC
   1580   Revolting old-fashioned language which lots of people understand
   1645   and use, and which runs surprisingly fast on lots of computers.
   1709   2 Forth
   1717   Forth combines fast execution with compact code and rapid program
   1783   development turnaround.  Other benefits are really sensational
   1846   gibberish code which no-one can ever understand, and a propensity
   1912   to spectacular crashes.
   1936

Where a help library includes references to other libraries, index entries like the following one appear:

     91   000002791 000000149 000000149 @cmnds 1 Commands

The corresponding keyword entry in the data region of the file is normal in appearance except that there are no text records.

5.4 The INCLUDE files

The files helpic and comic (on the Unix platforms – HELPIC.FOR and COMIC.FOR on the VAX, HELPIC and COMIC on the PC) contain definitions and COMMON declarations. They are included through “INCLUDE ’helpic’” and “INCLUDE ’comic’” statements, the interpretation of which is machine-dependent. The comic INCLUDE is used only by the “HLP_COMSTR” routine and exists in different forms for different platforms.

5.5 Subprograms

This section is a classified summary of the subprograms which make up the HLP package. For more complete information, including argument data types and character string lengths, it will be necessary to refer to the source code itself.

5.5.1 Supported interfaces

The following three routines, plus the templates described in the next section, constitute the supported interface to the HLP package. Use of any other HLP_ routines, or of the COMMON blocks used by the HLP system, is at the programmer’s own risk.

  SUBROUTINE HLP_ERRMES(J,MES)

HLP_ERRMES translates a HLP system error code J into a message string MES. See Section 4.6.

  SUBROUTINE HLP_CREH(NAMETR,LUIN,SOURCE,LUOUT,LIB,LUERR,EOS,JSTAT)

HLP_CREH translates a file of help source SOURCE, on I/O unit LUIN, into a help library LIB, subject to name translation by the routine NAMETR, on I/O unit LUOUT. Any error messages go to I/O unit LUERR. EOS is the end-of-string character, conventionally CHAR(0). JSTAT is the status. See Section 3.2.

  INTEGER FUNCTION HLP_HELP(OUTSUB,LOUT,INLINE,LU,LIB,JFLAGS,INSUB)

HLP_HELP is the main interface between an application and the HLP system, and carries out a complete interactive help session. Full details are given in Section 4.1.

5.5.2 Templates
  SUBROUTINE HLP_NAMETR(KMD,INSTR,OUTSTR,JSTAT)

This implementation of the user-supplied name translation routine is suitable for use in a multiple-platform environment. It forms each filename by sandwiching the library name within a prefix and a suffix. HLP_NAMETR, or a user-supplied equivalent, is called by the HLP system prior to opening any help library, always with KMD=0. The library name to be translated is supplied in INSTR, and the filename is returned in OUTSTR ready for use in a Fortran OPEN statement. See Section 4.4 for further details of the HLP_NAMETR routine supplied, which uses other KMD values to set and enquire the prefix and suffix strings.

  INTEGER FUNCTION HLP_INSUB(STRING,PROMPT,L)

This is a simple example of the user-supplied input routine which is to be called by the HLP_HELP routine each time an interactive response is required. STRING is the response received. PROMPT is the prompt string, output before STRING is solicited. L is the length of STRING, excluding any trailing spaces. The function returns the value +1 to indicate success. Note that the order of the arguments does not comply with Starlink standards (see SGP/16), a consequence of maintaining a family-resemblance with VMS Help. See Section 4.3. As well as being a template, HLP_INSUB is used in the LSTHLP and TSTHLP programs.

  INTEGER FUNCTION HLP_OUTSUB(STRING)

This is a simple example of the user-supplied output routine which is to be called by the HLP_HELP routine each time a line of help text is to be output. STRING is the string to be output. The function returns the value +1 to indicate success. See Section 4.2. As well as being a template, HLP_OUTSUB is called in the LSTHLP and TSTHLP programs.

5.5.3 String handling

The following routines overlap in function with ones found in other Starlink packages, but are included in the HLP package for independence.

  LOGICAL FUNCTION HLP_COMSTR(FULSTR,STR)

HLP_COMSTR compares two keywords for agreement, under the HLP package’s rules for abbreviation (see Section 2). FULSTR is the full keyword read from the HLP library; STR is the abbreviated string, including wildcards etc, supplied by the user. A .TRUE. response is returned if the two strings match.

  SUBROUTINE HLP_DEC(STRING,IPTR,NUM)

HLP_DEC decodes a decimal integer NUM from a string STRING, starting at position IPTR. The pointer IPTR is incremented ready for the next call.

  INTEGER FUNCTION HLP_LENGTH(STRING)

The HLP_LENGTH function returns the length of a string STRING excluding any trailing spaces. An all-blank string is length 1. The routine is optimized for speed in the case where the string is mostly trailing spaces.

  SUBROUTINE HLP_SPLIT(STRING,ISTART,IFROM,ITO)

HLP_SPLIT splits up a sentence into words. STRING consists of words separated by spaces. Starting at character position ISTART, this routine locates the beginning and end of the next word IFROM and ITO.

  SUBROUTINE HLP_UPCASE(STRING)

HLP_UPCASE converts a string STRING to uppercase, in place.

5.5.4 Variable-length random-access file package

help libraries are standard Fortran direct-access files, which have a fixed record length, on which the system implements a variable-length record scheme. The following routines manage these files. They communicate in part through labelled COMMON.

  SUBROUTINE HLP_HCLOSE(JSTAT)

HLP_HCLOSE closes the current help library. JSTAT is the status return.

  SUBROUTINE HLP_HDREAD(IADR,STRING,NC,JSTAT)

HLP_HDREAD performs a direct-access read from the current help library. IADR is the character address from which the read is to begin. STRING is the record that is found there, and NC its length. JSTAT is the status.

  SUBROUTINE HLP_HDWRIT(STRING,IADR,JSTAT)

HLP_HDWRIT performs a direct-access write to the current help library. IADR is the character address from which the write is to begin. STRING is the record to be written. JSTAT is the status.

  SUBROUTINE HLP_HINIT(LU,FNAME,EOS)

HLP_HINIT initializes the HLP system labelled COMMON blocks. LU is the I/O unit number to be used for accessing the help library file. FNAME is the initial help library name. EOS is the special character that will signify end-of-string, conventionally CHAR(0).

  SUBROUTINE HLP_HOPENR(NAMETR,JSTAT)

HLP_HOPENR opens or re-opens the current help library for reading, with the assistance of the library name to filename translation routine NAMETR. JSTAT is the status.

  SUBROUTINE HLP_HOPENW(NAMETR,NCHARS,JSTAT)

HLP_HOPENW opens the current help library for writing, with the assistance of the library name to filename translation routine NAMETR. NCHARS is the length of the file, which must be known before the call. JSTAT is the status.

5.5.5 Indexed-sequential package

The HLP system uses its variable-length direct-access file system, described above, to implement the indexed-sequential structure described in Section 5.3. The file has an index region and a data region. The index region contains three sets of pointers, to the data, to the next index entry down the branch, and the next index entry at the same level in the current branch.

  SUBROUTINE HLP_HREADD(STRING,NC,JSTAT)

HLP_HREADD performs a sequential-access read from the data region of the help library. The returned string STRING has length NC. JSTAT is the status.

  SUBROUTINE HLP_HREADX(NAMETR,NAVIG,STRING,NC,JSTAT)

HLP_HREADX reads the help library index, leaving the sequential-access addresses pointing to the indexed record. If it is necessary to translate a library name into a filename, the routine NAMETR will be called. NAVIG controls which track through the library is required – down the branch or along a level. STRING is the record input and NC its length. JSTAT is the status.

  SUBROUTINE HLP_HSEEKX(FNAME,IADRX,LOGLEV)

HLP_HSEEKX positions the index of the help library FNAME for a sequential access (using the HLP_HREADX routine) starting at character address IADRX. The caller also supplies LOGLEV, the logical level, which specifies the hierarchical level, on this occasion, of the help subtree contained in the library.

  SUBROUTINE HLP_HTELLX(FNAME,IADRX,LOGLEV)

HLP_HTELLX inquires the help library’s current name, index address and logical level.

5.5.6 Internal

The following are highly specialized internal routines, with no significant potential use outside the HLP system (and which are in any case inaccessible to users of the shareable libraries on VMS). For further details, see the source code.

  SUBROUTINE HLP_HCHKL(RECORD,LEVEL,NAME)
  SUBROUTINE HLP_HLEAP(NAMETR,STRING,FNAME,IADR,LOGL,JSTAT)
  SUBROUTINE HLP_LINOUT(OUTSUB,LOUT,INDENT,BUFFER,JSTAT)
  SUBROUTINE HLP_REPSUB(NAMETR,OUTSUB,LOUT,LEVCUR,NAME,OUTBUF,HLPBUF,ISTAT)
  SUBROUTINE HLP_FOPR (NAMETR,LU,FILE,LREC,JSTAT)

5.6 Rebuilding the System

On the VAX, the DCL command procedure CREATE.COM in the release directory rebuilds the object library, compiles and links the executable programs, generates the demonstration help library from source, and produces the Unix release. The latter consists of an archive file, a makefile, and a script mk which sets up environment variables and then runs make. For details about the targets supported, execute mk help.

5.7 VAX/VMS Logical Names

On VAX/VMS, in order to run applications using HLP the following logical names must be assigned:

logical name points to typical assignment
HLP_DIR HLP software STARDISK:[STARLINK.LIB.HELP]
HLP_IMAGE shareable library (non-ADAM) HLP_DIR:HLP_IMAGE.EXE
HLP_IMAGE_ADAM shareable library (ADAM) HLP_DIR:HLP_IMAGE_ADAM.EXE

In order to link a non-ADAM application with the shared library, the following additional assignment is required:

HLP_LINK link options file HLP_DIR:HLP_LINK.OPT