parm f1=funcdata.PUB,SEC="#GENERAL"
SETJCW INSIDEMPEX 0
IF !INSIDEMPEX = 0
   XEQ MAIN.PUB.VESOFT;INFO="FUNCKEYS !F1"
   RETURN
ENDIF
if not fexists("!f1")
   calc writempemessage(2,907)
   escape 907
endif
setvar rec_nbr 0
SETVAR OK_PROCESS 0
setvar fnum vefopen("!f1,old;acc=in")
TRAPERROR
while vefreadv("r1",fnum) do
   setvar key_label '![lft("!r1",16)]'
   setvar key_def '![rht("!r1",64)]'
   IF "!SEC" = "![RTRIM('!R1',' ')]"
      SETVAR OK_PROCESS 1
   ELSE
      if !OK_PROCESS = 1
         setvar rec_nbr rec_nbr + 1
         if !REC_NBR <= 8
            setvar stmt "![CHR(27)]&f2a![rec_nbr]"
            setvar stmt "!stmt"+"k16d64L!key_label!key_def![CHR(27)]&jB"
            echo !stmt
         ENDIF
      endif
   ENDIF
endwhile
CLEANUP
NOMSG calc vefclose(fnum)
NOMSG DELETEVAR REC_NBR OK_PROCESS FNUM R1 STMT
NOMSG DELETEVAR KEY_LABEL KEY_DEF
ENDCLEANUP

Here is an example of a data file this script reads

#GENERAL
RRHLOGON        XEQ RRHLOGON.PUB.HORNER
MPEX            XEQ MPEX.PUB.HORNER
QUAD            XEQ QT.PUB.HORNER
QUERY           RUN QUERYNM.PUB.SYS
LISTJOB         XEQ MPEX.PUB.HORNER LISTJOB
ME              XEQ ME.PUB.HORNER
TIME            XEQ TIME.PUB.HORNER
FUNCTIONKEYS    XEQ FUNCKEYS.PUB.HORNER
#QUAD
PAGE            PAGE
LIST ALLOFFLINE L A O
LIST ALL        L A
KEEP            K
RENUM           RENUM


EXIT            E