Post Reply 
(50g) FNINVARS: Object finder for couch hackers
10-16-2017, 12:01 AM
Post: #7
FLIBS: Library Finder for couch hackers
Several years ago when Joe Horn shared the FNINVARS program, I was also looking for a similar tool to report which libraries a program is using. After some (!) attempts and much patience from Joe, I came up with the following, somewhat brute force program, FLIBS, to do this:

Code:

%%HP: T(3)A(R)F(.);
\<<
  IF DUP TYPE 8. SAME NOT
  THEN "Not a program object!" DOERR
  ELSE
      TOHEX
    WHILE "
 " "
" SREPL
    REPEAT
    END
  END
  { } SWAP
  WHILE
      DUPDUP "
29E20" POS DUP
  REPEAT
      6. + DUP 2. + SUB
      ROT OVER "00" + H\->A B\->R R\->I \->STR + UNROT
      "
29E20" SWAP + "
XXXXXXXX" SREPL DROP
  END
  3. DROPN
\>>

Note this program requires TOHEX (I believe written by Joe):

Code:

%%HP: T(3)A(R)F(.);
\<<
  IF DUP BYTES NIP 2.5 ==
  THEN \->A DUP
    IFERR GETNAME 1. DISP 1. FREEZE
    THEN
    END A\->H
  ELSE DCOD
  END
\>>

which in turn requires DCOD, which I assume most folks have.

To use FLIBS to examine program PROG, recall your RPL program to the stack and run FLIBS;

[RS] 'PROG' FLIBS

The result is a list of the (decimal) library numbers utilized in the program.

The above dependency explanation is a perfect example of why such tools are so essential in RPL.

There almost has to be a better way to convert the format of the found library numbers for output, but in those early days of exploring RPL, I was pleased that even this ugly sequence worked OK.

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
FLIBS: Library Finder for couch hackers - rprosperi - 10-16-2017 12:01 AM



User(s) browsing this thread: 1 Guest(s)