Mainframe Utility: GETHELP

Return to Mainframe Utilities Page

Module


PROC 1 COMMAND MAXLINES(80) HELP
CONTROL NOFLUSH MSG ASIS
/**********************************************************************
/* UTILITY : GETHELP                                                  *
/* AUTHOR : DAVE MONTGOMERY                                           *
/* FUNCTION : TRAP THE MESSAGES FROM A TSO "HELP" COMMAND AND LOAD    *
/*            THEM INTO A DATASET.                                    *
/**********************************************************************
CLEAR
/*
ERROR DO
  SET RC = &LASTCC
  ERROR OFF
  WRITE ***
  WRITE *** ERROR (&RC) IN &SYSICMD,&SYSPCMD
  IF &DATATYPE(&RC) = NUM THEN EXIT CODE(&RC)
  ELSE EXIT CODE(16)
END
/*
ATTN DO
  SET CMD = &STR()
  &CMD
  EXIT CODE(0)
END
/*
  SET COMMAND = &SYSCAPS(&STR(&COMMAND))
  IF &COMMAND = &STR(?) THEN GOTO HELP
  IF &HELP = HELP THEN GOTO HELP
/*
  SET HNA      = &STR(HELP NOT AVAILABLE)
  IF &DATATYPE(&MAXLINES) = NUM THEN -
     IF &MAXLINES = 80 OR -
        &MAXLINES = 60 THEN GOTO START
  WRITE *** INVALID PARAMETER MAXLINES(&STR(&MAXLINES))
  WRITE *** GETHELP NOT PROCESSED
  GOTO EXIT
/*
START: -
  SET SYSOUTTRAP = 9999
  HELP &COMMAND
  SET MAXOUT = &SYSOUTLINE
  IF &MAXOUT = 0 THEN GOTO ERROR
  SET TEXT = &STR(&SYSOUTLINE1)
  SET L = &LENGTH(&STR(&TEXT))
  IF &L > 17 THEN -
     IF &SYSINDEX(&STR(&HNA),&STR(&TEXT)) > 0 THEN -
        GOTO ERROR
/*
  SET TITLE = &STR(   ---------- HELP TEXT FOR TSO COMMAND &COMMAND )
  SET FILENAME = &STR(&SYSUID..TEMP.&COMMAND)
  IF &SYSDSN('&FILENAME') = OK THEN DELETE '&FILENAME'
  ALLOCATE DATASET('&FILENAME') FILE(OUT) NEW CATALOG RECFM(F B A) -
           LRECL(80) BLKSIZE(6160) UNIT(SYSDA) VOLUME(WRK$$$) +
           SPACE(5 2) RELEASE
  OPENFILE OUT OUTPUT
  SET P = 99
/*
  SET N = 2
  DO WHILE &N <= &MAXOUT
     IF &P > &MAXLINES THEN -
        DO
          SET OUT = &STR(1   )
          PUTFILE OUT
          SET OUT = &STR(&TITLE)
          PUTFILE OUT
          SET OUT = &STR( )
          PUTFILE OUT
          SET P = 4
        END
     SET OUT = &STR(   &SYSNSUB(2,&&SYSOUTLINE&N))
     PUTFILE OUT
     SET N = &N + 1
     SET P = &P + 1
  END
/*
  CLOSFILE OUT
  FREE FILE(OUT)
  ERROR OFF
  ISPEXEC EDIT DATASET('&FILENAME')
  GOTO EXIT
/*
HELP: -
  WRITE *** HELP FOR CLIST GETHELP
  WRITE
  WRITE          FORMAT: GETHELP  MAXLINES(NN)
  WRITE
  WRITE           IS ANY VALID TSO COMMAND WHICH HAS HELP
  WRITE                    AVAILABLE THROUGH THE TSO HELP COMMAND
  WRITE
  WRITE          MAXLINES  IS AN OPTIONAL PARAMETER TO SET PAGE LENGTH
  WRITE                    NN MAY BE EITHER 60 OR 80 (DEFAULT IS 80)
  WRITE
  WRITE          GETHELP WILL CAPTURE THE  HELP TEXT THAT IS NORMALLY
  WRITE          DISPLAYED ON THE  USER'S  TERMINAL WHEN THE TSO HELP
  WRITE          COMMAND IS ENTERED.   THE TEXT IS STORED IN THE USER
  WRITE          FILE &SYSUID..TEMP..        A PAGE TITLE AND
  WRITE          CARRIAGE CONTROL CHARACTERS ARE ALSO INSERTED IN THE
  WRITE          FILE SO THAT IT MAY BE PRINTED.
  WRITE
  WRITE *** END OF HELP
  GOTO EXIT
/*
ERROR: -
  WRITE *** HELP NOT AVAILABLE
  WRITE *** COMMAND &STR(&COMMAND) NOT FOUND
EXIT: -
  EXIT
            


Documentation

 This utility allows you to enter TSO GETHELP commandname and press ENTER, and
 the help associated with &quot;commandname&quot; will be placed in a dataset and you will
 be taken into an edit of that dataset.  If the the help does not exist for that
 command, you will be given a message stating that.            


Leave a Reply

Your email address will not be published. Required fields are marked *