! THIS TECO MACRO will search thru RSX-11M-PLUS V2 system HELP files !$
! and will list the qualifiers available at ALL levels.              !$
! Usage: MUN HELPLEV,MCR [topic1 topic2 ... topic9]                  !$
!  or    MUN HELPLEV,DCL [topic1 .... ]^I^I^I^I     !$
! The first parameter after the word "HELP" is the name of the root  !$
!   .HLP file at which HELPLEV.TEC begins its search, e.g. MCR.HLP.  !$
! If a topic is given, HELPLEV.TEC lists subtopics under that topic. !$
!^I^I^I^I^I^I^I^I     !$
! Q-REGISTER USE:^I^I^I^I^I^I     !$
!^IQ0 -- Root help file name.^I^I^I^I     !$
!^IQ1-Q9 -- HELP qualifier words^I^I^I^I     !$
!^IQL -- numeric, level of help we are looking for.^I     !$
!       QL -- text, line of output                                   !$
!^IQC -- loop counter.^I^I^I^I^I     !$
!^IQF -- Macro to read indirect files.^I^I^I     !$
!       QF -- number, level of indirect files                        !$
!       QA -- text, stack of indirect file names.                    !$
!^I^I^I^I^I^I^I^I     !$
$
! Process command line and store qualifiers !$
@^A/Help file qualifiers for: /     ! Output commands to TI: !$
Z"E@I/MCR/'ZJ10I<ESC>13I<ESC> ! MUNG puts command line in buffer, insert CR/LF !$
0JHT$
0UL ! Set level to 0 !$
! Initialize qualifiers !$
@^U0%[1,2]% @^U1%1 % @^U2%2 % @^U3%3 % @^U4%4 % @^U5%5 % @^U6%6 % @^U7%7 % @^U8%8 % @^U9%9 %$
$
! Now strip off qualifiers if given and set up for searches !$
@:S/^EC/"FOFILE<ESC> ! If no valid characters left process file !$
 | ! else !$
  -C$
  <0A"C.,.+1:X0 +C|0;'> ! Append valid chars to register, or exit !$
  %L$
 '$
$
@:S/ /"FOFILE<ESC>' ! If no blank go process file !$
@:S/^EC/"FOFILE<ESC> ! If no valid characters left process file !$
 | ! else !$
  -C$
  <0A"C.,.+1:X1 +C|0;'> ! Append valid chars to register, or exit !$
  %L$
 '$
$
@:S/ /"FOFILE<ESC>' ! If no blank go process file !$
@:S/^EC/"FOFILE<ESC> ! If no valid characters left process file !$
 | ! else !$
  -C$
  <0A"C.,.+1:X2 +C|0;'> ! Append valid chars to register, or exit !$
  %L$
 '$
$
@:S/ /"FOFILE<ESC>' ! If no blank go process file !$
@:S/^EC/"FOFILE<ESC> ! If no valid characters left process file !$
 | ! else !$
  -C$
  <0A"C.,.+1:X3 +C|0;'> ! Append valid chars to register, or exit !$
  %L$
 '$
$
@:S/ /"FOFILE<ESC>' ! If no blank go process file !$
@:S/^EC/"FOFILE<ESC> ! If no valid characters left process file !$
 | ! else !$
  -C$
  <0A"C.,.+1:X4 +C|0;'> ! Append valid chars to register, or exit !$
  %L$
 '$
$
@:S/ /"FOFILE<ESC>' ! If no blank go process file !$
@:S/^EC/"FOFILE<ESC> ! If no valid characters left process file !$
 | ! else !$
  -C$
  <0A"C.,.+1:X5 +C|0;'> ! Append valid chars to register, or exit !$
  %L$
 '$
$
@:S/ /"FOFILE<ESC>' ! If no blank go process file !$
@:S/^EC/"FOFILE<ESC> ! If no valid characters left process file !$
 | ! else !$
  -C$
  <0A"C.,.+1:X6 +C|0;'> ! Append valid chars to register, or exit !$
  %L$
 '$
$
@:S/ /"FOFILE<ESC>' ! If no blank go process file !$
@:S/^EC/"FOFILE<ESC> ! If no valid characters left process file !$
 | ! else !$
  -C$
  <0A"C.,.+1:X7 +C|0;'> ! Append valid chars to register, or exit !$
  %L$
 '$
$
@:S/ /"FOFILE<ESC>' ! If no blank go process file !$
@:S/^EC/"FOFILE<ESC> ! If no valid characters left process file !$
 | ! else !$
  -C$
  <0A"C.,.+1:X8 +C|0;'> ! Append valid chars to register, or exit !$
  %L$
 '$
$
@:S/ /"FOFILE<ESC>' ! If no blank go process file !$
@:S/^EC/"FOFILE<ESC> ! If no valid characters left process file !$
 | ! else !$
  -C$
  <0A"C.,.+1:X9 +C|0;'> ! Append valid chars to register, or exit !$
  %L$
 '$
$
!FILE!$
HK ! Clear buffer !$
QL"=%L  ! If no qualifiers given, force one !$
    ER[1,2]MCR.HLP<ESC>Y    ! and use MCR.HLP by default !$
  | ! else !$
    ! use first qualifier as root file name and open it !$
    @I/:ER/G0 @I/.HLP<ESC>"NY|@^A%No such file as %:G0 HKEKEX<ESC>'/$
    HXF HK ! command into QF !$
    MF       ! read the file !$
  '$
1UC     ! set count to one !$
QL<     ! repeat this mess "level" times !$
   (QL-QC)"G ! not lowest level yet !$
     ! Search for appropriate level qualifier; only 1 of 9 executes !$
!POS!(1-QC)"E@:_/^EQ1/US'$
     (2-QC)"E@:_/^EQ2/US'$
     (3-QC)"E@:_/^EQ3/US'$
     (4-QC)"E@:_/^EQ4/US'$
     (5-QC)"E@:_/^EQ5/US'$
     (6-QC)"E@:_/^EQ6/US'$
     (7-QC)"E@:_/^EQ7/US'$
     (8-QC)"E@:_/^EQ8/US'$
     (9-QC)"E@:_/^EQ9/US'$
     QS"F:G_ @^A/ not found/ OEND<ESC>'$
     L <(0A-32)"ED|0;'>  ! next line, strip leading blanks !$
     (0A-35)"E C      ! is it a synonym? if so must look for its synonym !$
              .UA L-2C QA,.X0  ! put syn. into Q0 (not needed no more) !$
              ! now reset the appropriate search register and go back !$
              ! first reset cursor ! 0L$
              @^UF%[0 ]% (QC+48):^UF<ESC> @^UF%<ESC>% @^UF%<ESC>% MF OPOS<ESC>$
             '$
     (0A-64)"E C        ! if @, must open indirect file !$
              @^UF%:ER[1,2]% ! Put UIC into QF !$
              .UA @S/$
/$
              -2C QA,.:XF ! append file name !$
              :@^UF%.HLP<ESC>"NY|@^A/No such file as /:G*HKEKEX'%$
              @:^UF%%     ! and extension, and open commands !$
              @:^UF%%    ! Terminate macro !$
              HK MF    ! clear buffer and output file name, open file !$
             ' ! end of opening indirect file !$
     %C ! increment count !$
     | ! else we ARE at lowest level !$
     < ! loop to output HELP qualifiers at next lowest level !$
       ! search for a qualifier line, any digit !$
!SCAN! @:_/$
^ED /$
       "F! end of file, See if we are indirected !$
         QF"G ! we are, return back up a level !$
            -1%F]A]XHK @^UF%:ER% GAH:XF @:^UF%<ESC>"LY$
                                 |@^A/No such file as /:G*HKEKEX'%$
            @:^UF%<ESC>%@:^UF%<ESC>%$
            MF QXJ$
            OSCAN<ESC>$
            |OEND<ESC>'  ! failed, no more, quit !$
       '$
       -2C ! is it equal or greater level !$
       (0A-48-QL)"LOEND<ESC>'  ! NO, we quit !$
       .UX ! save position !$
       0,0XL  ! clear QL !$
       (0A-48)<@:^UL%  %>    ! indent for level !$
       L-2CQX,.:XL<ESC>     ! and add text !$
       L.UX<(0A-32)"ED|0;'>  ! next line, strip leading blanks !$
       (0A-35)"E C      ! is it a synonym? if so must look for its synonym !$
              @:^UL% (See %$
              .UA L-2C QA,.:XL<ESC> QXJ  ! put syn. into line !$
              @:^UL%)%$
              '$
       13:^UL<ESC>10:^UL<ESC>:GL  ! Append CR/LF and output it all !$
       (0A-64)"E C        ! if @, must open indirect file !$
              [X          ! push cursor position onto stack !$
              %F<ESC>         ! increment indirect level count !$
              @^UF%:ER[1,2]% ! Put UIC into QF !$
              .UA @S/$
/$
              -2C QA,.:XF ! append file name !$
              HKG*HXA[AHK ! push old file name onto stack !$
              :@^UF%.HLP<ESC>"NY|@^A/No such file as /:G*HKEKEX'%$
              @:^UF%<ESC>%     ! and extension, and open commands !$
              @:^UF%<ESC>%    ! Terminate macro !$
              MF    ! clear buffer and output file name, open file !$
             ' ! end of opening indirect file !$
      > ! end of output loop !$
     '  ! end of else we are !$
  >     ! end of search down levels !$
!END!$
HK EX<ESC><ESC>$
