!   "FINDLABEL" -- Program to find address in xxx.SYM file...
!                  and print name of corresponding label
!   REVISION HISTORY:
!       Version 1.0 2/21/81
!            First release. Hunted for "ASMLOG.TMP" file.
!       Version 1.0b 4/24/82
!            Hunts for "DEBUG.SYM" file automatically.
    DIM VERSION$/"Find BASIC Label v1.0B"/
    DIM FILE$(50)
    DIM LINE$(150),LABEL$(5)
    IF COL(0)<>1
    THEN
        INPUT '' LABEL$
        PRINT Version$
    ELSE
        PRINT Version$
        INPUT "Find name of Label whose address is: " LABEL$
    FI
    ON ERROR GOTO BADADDRESS
    IF LABEL$(1,1)<>":" THEN LET LABEL$=":" CAT LABEL$
    LET LABEL$=HEX$(VAL(LABEL$))\! REM FORCE TO STANDARD FORMAT
    LET LABEL$(1,1)="/"
START: LET FILE$="DEBUG.SYM"
TRYFILE: ON ERROR GOTO CANTFIND
    OPEN #1,FILE$
    ON ERROR GOTO 0
LOOP: INPUT #1,LINE$
    IF EOF(1) THEN EXIT
    IF FIND(LINE$,"Symbols Sorted by Value")<>0 THEN EXIT
    IF FIND(LINE$,LABEL$)=0 THEN LOOP
    FOR I=FIND(LINE$,LABEL$) TO 1 STEP -1 UNTIL LINE$(I,1)=" " DO REM
    LET I=I+1
    PRINT LINE$(I,FIND(LINE$,LABEL$)+5-I)
    GOTO LOOP

BADADDRESS: PRINT "Must enter Hexadecimal address." \ EXIT

CANTFIND:
    INPUT "Where's the Symbol table file? " FILE$
    GOTO TRYFILE
    END
