Every time PureBasic starts up, it creates a file called PBFunctionListing.txt that contains a list of all functions that PureBasic currently knows about which includes installed user libraries and the comments for each of those commands.
When a new version of PureBasic is released and there are no documents for it, that's where us inexperienced coders go to find out what commands PureBasic currently knows about that we might have missed. Now, this document is a little hard to read as it isn't formatted with proper CR/LF as it comes from the compiler, we need a simpler way of reading it.
1. To create a clean (PureBasic commands only) document, without user library commands,
a. Exit purebasic completely.
b. Temporarily move any libraries in the PureBasic\PureLibraries\UserLibraries folder to a safe place.
c. Restart PureBasic.
d. Exit purebasic completely.
e. Copy the PBFunctionListing.txt to a safe place.
f. Move your user libraries back to PureBasic\PureLibraries\UserLibraries
Now you have a listing of all the internal commands that PureBasic supports, along with their comments.
And if you find the document hard to read, either convert it (write code to do it yourself, a good way to learn!!) or use my viewer/searcher below if it's more convenient.
Code: Select all
Structure PBFileIndexList
Function.s
Comment.s
EndStructure
;============================================================================================================================
;
;============================================================================================================================
Global OldTitle.s = "View pb Functions and parameters", PBFileItemCount.l
NewList PBFl.PBFileIndexList()
;============================================================================================================================
;
;============================================================================================================================
Enumeration 1
#Window_viewfunction
#Window_functionbox
EndEnumeration
#WindowIndex = #PB_Compiler_EnumerationValue
Enumeration 1
#Gadget_viewfunction_flist
#Gadget_viewfunction_bgetlist
#Gadget_viewfunction_bsavelist
#Gadget_viewfunction_ssearch
#Gadget_viewfunction_cfield
#Gadget_functionbox_pbfunction
#Gadget_functionbox_pbcomment
#Shortcut_functionbox_escape
#Shortcut_viewfunction_enter
EndEnumeration
#GadgetIndex = #PB_Compiler_EnumerationValue
;============================================================================================================================
;
;============================================================================================================================
Procedure.l Window_viewfunction()
If OpenWindow(#Window_viewfunction,64,69,750,600,OldTitle,#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered|#PB_Window_Invisible)
ListIconGadget(#Gadget_viewfunction_flist,0,0,750,577,"Function",300,#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection)
AddGadgetColumn(#Gadget_viewfunction_flist,1,"Explanation",2000)
ButtonGadget(#Gadget_viewfunction_bgetlist,0,580,60,20,"Get List")
ButtonGadget(#Gadget_viewfunction_bsavelist,60,580,60,20,"Save list")
StringGadget(#Gadget_viewfunction_ssearch,125,580,500,20,"")
ComboBoxGadget(#Gadget_viewfunction_cfield,625,580,125,200)
HideWindow(#Window_viewfunction,0)
ProcedureReturn WindowID(#Window_viewfunction)
; EndIf
EndIf
EndProcedure
;============================================================================================================================
;
;============================================================================================================================
Procedure.l Window_functionbox()
If OpenWindow(#Window_functionbox,162,228,500,180,"Show the function and its' description",#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered|#PB_Window_Invisible,WindowID(#Window_viewfunction))
StringGadget(#Gadget_functionbox_pbfunction,0,0,500,20,"")
EditorGadget(#Gadget_functionbox_pbcomment,0,25,500,150)
HideWindow(#Window_functionbox,0)
ProcedureReturn WindowID(#Window_functionbox)
; EndIf
EndIf
EndProcedure
;============================================================================================================================
;
;============================================================================================================================
If Window_viewfunction()
AddKeyboardShortcut(#Window_viewfunction, #PB_Shortcut_Return, #Shortcut_viewfunction_enter)
QuitValue = 0
AddGadgetItem(#Gadget_viewfunction_cfield, -1, "Function")
AddGadgetItem(#Gadget_viewfunction_cfield, -1, "Comment")
AddGadgetItem(#Gadget_viewfunction_cfield, -1, "Both")
SetGadgetState(#Gadget_viewfunction_cfield, 2)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Select EventWindow()
Case #Window_viewfunction : QuitValue = 1
Case #Window_functionbox : Gosub CloseFunctionBox
EndSelect
Case #PB_Event_Menu
Select EventMenu()
Case #Shortcut_viewfunction_enter : Gosub StartFunctionSearch
Case #Shortcut_functionbox_escape : Gosub CloseFunctionBox
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
Case #Gadget_viewfunction_flist
Select EventType()
Case #PB_EventType_LeftDoubleClick : Gosub ShowFunctionBox
EndSelect
Case #Gadget_viewfunction_bgetlist : Gosub GetFunctionList
Case #Gadget_viewfunction_bsavelist : Gosub SaveFunctionList
EndSelect
EndSelect
Until QuitValue
CloseWindow(#Window_viewfunction)
EndIf
End
;============================================================================================================================
GetFunctionList:
;============================================================================================================================
PBFileName.s = OpenFileRequester("Open PB Function Listing","PBFunctionListing.txt","Text (*.txt)|*.txt;*.asc;*.bat", 0)
If PBFileName.s <> ""
PBFileID = ReadFile(#PB_Any, PBFileName.s)
If PBFileID
If ListSize(Pbfl.s()) <> 0
ClearList(Pbfl.s())
EndIf
FileCounter = 0
PBFileBuffer.s = ReadString(PBFileID, 0)
SetWindowTitle(#Window_viewfunction, OldTitle + " - (" + PBFileBuffer + ") Functions found")
While Eof(PBFileID) = 0
PBFileBuffer.s = ReadString(PBFileID, 0) ; Read a string from the file
PBFileBufferLength.l = Len(PBFileBuffer)
PBFileSeparatorPos.l = FindString(PBFileBuffer, " - ", 1) ; Find the delimiter if any
If PBFileSeparatorPos
PBFileFunction.s = Left(PBFileBuffer, PBFileSeparatorPos) ; Only need to go as far as the delimiter
PBFileComment.s = Mid(PBFileBuffer, PBFileSeparatorPos + 3, PBFileBufferLength - PBFileSeparatorPos)
FileCounter + 1
AddGadgetItem(#Gadget_viewfunction_flist, -1, PBFileFunction + Chr(10) + PBFileComment)
AddElement(Pbfl.s())
Pbfl()\Function = PBFileFunction.s
Pbfl()\Comment = PBFileComment.s
SendMessage_(GadgetID(#Gadget_viewfunction_flist), #LVM_ENSUREVISIBLE, FileCounter -1, 0) ; Make sure the current line is visible
EndIf
Wend
EndIf
CloseFile(PBFileID)
PBFileItemCount = CountGadgetItems(#Gadget_viewfunction_flist)
EndIf
Return
;============================================================================================================================
SaveFunctionList:
;============================================================================================================================
PBFileName.s = SaveFileRequester("Open PB Function Listing","PBFunctionListing.New","Text (*.txt)|*.txt;*.asc;*.bat", 0)
If PBFileName.s <> ""
PBFileID = CreateFile(#PB_Any, PBFileName.s)
If PBFileID
For PBFileItems.l = 0 To PBFileItemCount - 1
PBFileFunction.s = GetGadgetItemText(#Gadget_viewfunction_flist, PBFileItems, 0)
PBFileComment.s = GetGadgetItemText(#Gadget_viewfunction_flist, PBFileItems, 1)
WriteStringN(PBFileID, PBFileFunction + Chr(09) + PBFileComment)
Next
EndIf
CloseFile(PBFileID)
EndIf
Return
;============================================================================================================================
StartFunctionSearch:
;============================================================================================================================
FocusID = GetFocus_()
Select FocusID
Case GadgetID(#Gadget_viewfunction_ssearch)
For PBFileItems.l = 0 To PBFileItemCount - 1
SetGadgetItemColor(#Gadget_viewfunction_flist, PBFileItems, #PB_Gadget_BackColor, $FFFFFF)
SetGadgetItemColor(#Gadget_viewfunction_flist, PBFileItems, #PB_Gadget_FrontColor, $000000)
Next
PBFileSearch.s = LCase(GetGadgetText(#Gadget_viewfunction_ssearch))
PBFileField.s = GetGadgetText(#Gadget_viewfunction_cfield)
For PBFileItems.l = 0 To PBFileItemCount - 1
PBFileFunction.s = LCase(GetGadgetItemText(#Gadget_viewfunction_flist, PBFileItems, 0))
PBFileComment.s = LCase(GetGadgetItemText(#Gadget_viewfunction_flist, PBFileItems, 1))
Select PBFileField
Case "Both"
PBFileStringToSearch.s = PBFileFunction + PBFileComment
Case "Function"
PBFileStringToSearch.s = PBFileFunction
Case "Comment"
PBFileStringToSearch.s = PBFileComment
EndSelect
If FindString(PBFileStringToSearch, PBFileSearch, 1) <> 0
SendMessage_(GadgetID(#Gadget_viewfunction_flist), #LVM_ENSUREVISIBLE, PBFileItems, 0)
SetGadgetItemColor(#Gadget_viewfunction_flist, PBFileItems, #PB_Gadget_BackColor, 2329400)
SetGadgetItemColor(#Gadget_viewfunction_flist, PBFileItems, #PB_Gadget_FrontColor, $FFFFFF)
SetActiveGadget(#Gadget_viewfunction_ssearch)
EndIf
Next
Case GadgetID(#Gadget_viewfunction_flist)
Gosub ShowFunctionBox
EndSelect
Return
;============================================================================================================================
ShowFunctionBox:
;============================================================================================================================
If Window_functionbox()
AddKeyboardShortcut(#Window_functionbox, #PB_Shortcut_Escape, #Shortcut_functionbox_escape)
SendMessage_(GadgetID(#Gadget_functionbox_pbcomment), #EM_SETTARGETDEVICE, #Null, 0) ; Set wordwrap in comment box
PBFileLine.l = GetGadgetState(#Gadget_viewfunction_flist)
If PBFileLine <> -1
SetGadgetText(#Gadget_functionbox_pbfunction, GetGadgetItemText(#Gadget_viewfunction_flist, PBFileLine, 0))
SetGadgetText(#Gadget_functionbox_pbcomment, GetGadgetItemText(#Gadget_viewfunction_flist, PBFileLine, 1))
EndIf
EndIf
Return
;============================================================================================================================
CloseFunctionBox:
;============================================================================================================================
CloseWindow(#Window_functionbox)
SetActiveGadget(#Gadget_viewfunction_flist)
SetGadgetItemState(#Gadget_viewfunction_flist, PBFileLine, #PB_ListIcon_Selected)
Return