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

Just starting out? Need help? Post your questions and find answers here.
Marco2007
Enthusiast
Enthusiast
Posts: 648
Joined: Tue Jun 12, 2007 10:30 am
Location: not there...

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

Post 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!
PureBasic for Windows
boddhi
Enthusiast
Enthusiast
Posts: 524
Joined: Mon Nov 15, 2010 9:53 pm

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

Post 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
Last edited by boddhi on Fri May 24, 2024 10:26 pm, edited 2 times in total.
If my English syntax and lexicon are incorrect, please bear with Google translate and DeepL. They rarely agree with each other!
Except on this sentence...
Marco2007
Enthusiast
Enthusiast
Posts: 648
Joined: Tue Jun 12, 2007 10:30 am
Location: not there...

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

Post by Marco2007 »

Thanks! ☺️
PureBasic for Windows
boddhi
Enthusiast
Enthusiast
Posts: 524
Joined: Mon Nov 15, 2010 9:53 pm

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

Post 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:
If my English syntax and lexicon are incorrect, please bear with Google translate and DeepL. They rarely agree with each other!
Except on this sentence...
Marco2007
Enthusiast
Enthusiast
Posts: 648
Joined: Tue Jun 12, 2007 10:30 am
Location: not there...

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

Post by Marco2007 »

Yes, I was just unsure, if code outside call() ist allowed, when it's in another procedure. 😊👍
PureBasic for Windows
Post Reply