examine userlibs ?

Everything else that doesn't fall into one of the other PB categories.
User avatar
Hroudtwolf
Addict
Addict
Posts: 803
Joined: Sat Feb 12, 2005 3:35 am
Location: Germany(Hessen)
Contact:

examine userlibs ?

Post by Hroudtwolf »

Hello PB-World,

Is it possible to examine all function from a userlib ?
If it is possible ??... How to do it ?
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post by El_Choni »

I use this code:

Code: Select all

Structure finfo
  FunName.s
  Args.s
  HelpLine.s
EndStructure

NewList allfunctions.finfo()

Structure Seeker
  StructureUnion
    b.b
    w.w
    l.l
  EndStructureUnion
EndStructure

Procedure ShowLibInfo(LibFile$)
  LibName$ = GetFilePart(LibFile$)
  If ReadFile(0, LibFile$)
    LibSize = Lof()
    *LibHeader = AllocateMemory(LibSize)
    ReadData(*LibHeader, LibSize)
    CloseFile(0)
    *LibEnd = *LibHeader+LibSize
    *LHSeeker.Seeker = *LibHeader
    If *LHSeeker\l='PURE' And PeekL(*LHSeeker+8)='LIB3' And PeekL(*LHSeeker+16)='3BIL'
      *LHSeeker.Seeker = *LibHeader+20
      While *LHSeeker\b<>0:*LHSeeker+1:Wend
      *LHSeeker+2
      If *LHSeeker>=*LibEnd:ProcedureReturn:EndIf
      nDLL = *LHSeeker\b
      If nDLL
        For i=1 To nDLL
          *LHSeeker+1
          DLL$+", "+PeekS(*LHSeeker)
          *LHSeeker+Len(PeekS(*LHSeeker))
        Next i
        DLL$ = Right(DLL$, Len(DLL$)-2)
        *LHSeeker+1
      EndIf
      *LHSeeker+1
      While *LHSeeker\b<>0:*LHSeeker+1:Wend
      *LHSeeker+1
      If *LHSeeker>=*LibEnd:ProcedureReturn:EndIf
      nPL = *LHSeeker\b
      If nPL
        For i=1 To nPL
          *LHSeeker+1
          nPL$+", "+PeekS(*LHSeeker)
          *LHSeeker+Len(PeekS(*LHSeeker))
        Next i
        nPL$ = Right(nPL$, Len(nPL$)-2)
      EndIf
      *LHSeeker+1
      If *LHSeeker>=*LibEnd:ProcedureReturn:EndIf
      While PeekL(*LHSeeker)<>'PURE' And PeekL(*LHSeeker+8)<>'DAT1'
        AddElement(allfunctions())
        allfunctions()\FunName = PeekS(*LHSeeker)
        *LHSeeker+Len(allfunctions()\FunName)+1
        *LHSeeker+*LHSeeker\b+5
        While *LHSeeker\b=0:*LHSeeker+1:Wend
        allfunctions()\Args = ""
        allfunctions()\HelpLine = ""
        If *LHSeeker\b='('
          arging = 1
          While *LHSeeker\b<>0
            If *LHSeeker\b='-'
              arging = 0
            EndIf
            If arging
              allfunctions()\Args+Chr(*LHSeeker\b)
            Else
              allfunctions()\HelpLine+Chr(*LHSeeker\b)
            EndIf
            *LHSeeker+1
          Wend
          allfunctions()\Args = LTrim(RTrim(allfunctions()\Args))
          allfunctions()\HelpLine = LTrim(RTrim(RemoveString(allfunctions()\HelpLine, "- ")))
          *LHSeeker+1
        EndIf
      Wend
    EndIf
    FreeMemory(*LibHeader)
  EndIf
  Debug "Library: "+LibName$
  Debug "PureLibraries used: "+nPL$
  Debug "DLLs used: "+DLL$
  ForEach allfunctions()
    Debug ""
    Debug "Function: "+allfunctions()\FunName
    Debug "Arguments: "+allfunctions()\Args
    Debug "Quick help: "+allfunctions()\HelpLine
  Next
  ClearList(allfunctions())
EndProcedure

Lib$ = "E:\Archivos de programa\PureBasic\PureLibraries\GadgetExtension"

ShowLibInfo(Lib$)
El_Choni
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

Post by NoahPhense »

Oh how sweet...

Thanks El!

- np
User avatar
Hroudtwolf
Addict
Addict
Posts: 803
Joined: Sat Feb 12, 2005 3:35 am
Location: Germany(Hessen)
Contact:

Post by Hroudtwolf »

Hey... Thank you :-)

You made an old man very happy :D
Intrigued
Enthusiast
Enthusiast
Posts: 501
Joined: Thu Jun 02, 2005 3:55 am
Location: U.S.A.

Post by Intrigued »

Thanks for posting this informative HOW-TO PB project file!

*thumbs up*
Intrigued - Registered PureBasic, lifetime updates user
jack
Addict
Addict
Posts: 1358
Joined: Fri Apr 25, 2003 11:10 pm

Post by jack »

cool! :D
Post Reply