Habe hier noch einen alten Code der zusätzlich zu Strukturen noch Informationen über Interfaces und Prozeduren holt.
GetPBInfo.pb:
Code: Alles auswählen
CompilerIf #PB_Compiler_Unicode
CompilerError "Please turn off compiler option 'Create unicode executable'"
CompilerEndIf
EnableExplicit
#Compiler = #PB_Compiler_Home+"compilers\pbcompiler.exe"
Procedure StartCompiler()
ProcedureReturn RunProgram(#Compiler,"/STANDBY","",#PB_Program_Open|#PB_Program_Read|#PB_Program_Write|#PB_Program_Hide)
EndProcedure
Procedure StopCompiler(compiler)
WriteProgramStringN(compiler, "END")
WaitProgram(compiler,5000)
CloseProgram(compiler)
EndProcedure
Procedure SendCompilerCommand(compiler,command$)
If ProgramRunning(compiler)
WriteProgramStringN(compiler, command$)
EndIf
EndProcedure
Procedure.s GetCompilerOutput(compiler)
If AvailableProgramOutput(compiler)
ProcedureReturn ReadProgramString(compiler)
EndIf
EndProcedure
Procedure FillList(compiler,List out.s(),space=0)
Protected out$
Protected space$=Space(space)
While out$<>"OUTPUT"+#TAB$+"COMPLETE" And Left(out$,5)<>"ERROR"
out$=GetCompilerOutput(compiler)
If out$ And out$<>"OUTPUT"+#TAB$+"COMPLETE" And Left(out$,5)<>"ERROR" And FindString("0123456789",Mid(out$,1,1))=0
AddElement(out())
out()=space$+out$
EndIf
Wend
EndProcedure
Procedure GetStructureList(compiler,List out.s())
If ProgramRunning(compiler)
SendCompilerCommand(compiler,"STRUCTURELIST")
FillList(compiler,out())
EndIf
EndProcedure
Procedure GetProcedureList(compiler,List out.s())
If ProgramRunning(compiler)
SendCompilerCommand(compiler,"FUNCTIONLIST")
FillList(compiler,out())
EndIf
EndProcedure
Procedure GetInterfaceList(compiler,List out.s())
If ProgramRunning(compiler)
SendCompilerCommand(compiler,"INTERFACELIST")
FillList(compiler,out())
EndIf
EndProcedure
Procedure GetStructureInfo(compiler,struct$,List out.s())
If ProgramRunning(compiler)
SendCompilerCommand(compiler,"STRUCTURE"+#TAB$+struct$)
FillList(compiler,out(),4)
EndIf
EndProcedure
Procedure GetInterfaceInfo(compiler,interf$,List out.s())
If ProgramRunning(compiler)
SendCompilerCommand(compiler,"INTERFACE"+#TAB$+interf$)
FillList(compiler,out(),4)
EndIf
EndProcedure
Procedure WaitCompilerReady(compiler)
Protected out$
While out$<>"READY" And Left(out$,5)<>"ERROR"
out$ = GetCompilerOutput(compiler)
If out$
Debug out$
EndIf
Wend
EndProcedure
Define pb, out$
NewList structures.s()
NewList procedures.s()
NewList interfaces.s()
NewList structureInfo.s()
NewList interfaceInfo.s()
pb = StartCompiler()
If pb
WaitCompilerReady(pb)
GetStructureList(pb,structures())
Debug "found "+Str(ListSize(structures()))+" structures"
GetProcedureList(pb,procedures())
Debug "found "+Str(ListSize(procedures()))+" procedures"
GetInterfaceList(pb,interfaces())
Debug "found "+Str(ListSize(interfaces()))+" interfaces"
ClearList(structureInfo())
ForEach structures()
AddElement(structureInfo())
structureInfo()="Structure "+structures()
GetStructureInfo(pb,structures(),structureInfo())
AddElement(structureInfo())
structureInfo()="EndStructure"
AddElement(structureInfo())
structureInfo()=""
Next
ClearList(interfaceInfo())
ForEach interfaces()
AddElement(interfaceInfo())
interfaceInfo()="Interface "+interfaces()
GetInterfaceInfo(pb,interfaces(),interfaceInfo())
AddElement(interfaceInfo())
interfaceInfo()="EndInterface"
AddElement(interfaceInfo())
interfaceInfo()=""
Next
If CreateFile(0,GetPathPart(ProgramFilename())+"Structures.pb")
ForEach structureInfo()
WriteStringN(0,structureInfo())
Next
CloseFile(0)
EndIf
If CreateFile(0,GetPathPart(ProgramFilename())+"Interfaces.pb")
ForEach interfaceInfo()
WriteStringN(0,interfaceInfo())
Next
CloseFile(0)
EndIf
If CreateFile(0,GetPathPart(ProgramFilename())+"Procedures.pb")
ForEach procedures()
WriteStringN(0,procedures())
Next
CloseFile(0)
EndIf
StopCompiler(pb)
Debug "Finish."
EndIf
Der Code schreibt am Ende 3 Dateien (Structures.pb, Interfaces.pb, Procedures.pb) mit den Informationen vom Compiler.