Page 1 of 1

When writing a DLL, all the code is done inside procedures.

Posted: Fri May 24, 2024 10:00 pm
by Marco2007
Hello everyone,

is this allowed?

Code: Select all

;PureBasic.dll
ProcedureDLL test()
;do something
EndProcedure 

ProcedureDLL call()
;do someehing and call 
test()
EndProcedure 

Code: Select all

If OpenLibrary(0, "PureBasic.dll")
  CallFunction(0, "call")
  CloseLibrary(0)
EndIf


It works, but I don't know, if there could be issues, because of
Don't write program code outside procedures. The only exception is the declaration of variables or structures.
I'm not sure ...

Thanks!

Re: When writing a DLL, all the code is done inside procedures.

Posted: Fri May 24, 2024 10:20 pm
by boddhi
Hello,
Marco2007 wrote: Don't write program code outside procedures. The only exception is the declaration of variables or structures.
All is said! :wink:

But if you don't plan to call the Test() procedure from outside the lib, this will be fine:

Code: Select all

;PureBasic.dll
Procedure test() ; <=== See here
;do something
EndProcedure 

ProcedureDLL call()
;do someehing and call 
test()
EndProcedure 
[EDIT] Note : Variables and structures outside procedures but constants (enumerations included) and include files too

Re: When writing a DLL, all the code is done inside procedures.

Posted: Fri May 24, 2024 10:25 pm
by Marco2007
Thanks! ☺️

Re: When writing a DLL, all the code is done inside procedures.

Posted: Fri May 24, 2024 10:33 pm
by boddhi
Marco2007 wrote: Thanks! ☺️
You've read my reply before I have the time to modify it.
See {EDIT] on my previous post. :wink:

Re: When writing a DLL, all the code is done inside procedures.

Posted: Sat May 25, 2024 7:38 am
by Marco2007
Yes, I was just unsure, if code outside call() ist allowed, when it's in another procedure. 😊👍