If 0 = OpenLibrary(0, "USER32.DLL") : End : EndIf
Prototype.i ProtoMessageBox(Window.i, Body$, Title$, Flags.i = 0)
; 'MsgBox' is a variable with a 'ProtoMessageBox' type
;
MsgBox.ProtoMessageBox = GetFunction(0, "MessageBoxW")
;Declare MsgBox(Window.i, Body$, Title$, Flags.i = 0) ; if uncommented errors: prototype already declared
Procedure.s msg(a.s)
MsgBox(0, "Hello", a) ; errors: MsgBox() is not a function
ProcedureReturn a
EndProcedure
res = msg("World")
Debug res
CloseLibrary(0)
EnableExplicit
Prototype.i ProtoMessageBox(Window.i, Body$, Title$, Flags.i = 0)
If OpenLibrary(0, "User32.dll")
; 'MsgBox' is a variable with a 'ProtoMessageBox' type
;
Global MsgBox.ProtoMessageBox = GetFunction(0, "MessageBoxW")
MsgBox(0, "Hello", "World") ; We don't specify the flags
EndIf
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Enableexlicit also has nothing to do with Prototype,
it is used to detect typos.
You have to declare each variable so that no errors occur....
and if you misspell the variable name the compiler will throw an error message.
This saves a lot of debugging!
PureBasic 6.10 LTS (Windows x86/x64) | Windows10 Pro x64 | Asus TUF X570 Gaming Plus | R9 5900X | 64GB RAM | GeForce RTX 3080 TI iChill X4 | HAF XF Evo | build by vannicom
English is not my native language... (I often use DeepL to translate my texts.)