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.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom
English is not my native language... (I often use DeepL.)