Please new constant: "#PB_Declare"

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Ulix
User
User
Posts: 48
Joined: Wed Jan 23, 2008 12:45 pm
Location: France, Montpellier

Please new constant: "#PB_Declare"

Post by Ulix »

Translation by google!

A new constant: "#PB_Declare" for the instruction: Defined (Name, Type) :?:

Good morning all !

For this I use twice:
"CompilerIf Defined (ProcessName, #PB_Procedure)".
- a first test during the declaration: Declare ....
- a second test during the procedure itself: Procedure ...

Apparently if I use:
"CompilerIf Defined (NomDeProcedure, #PB_Procedure)" to test for the presence of the declaration, then the procedure is no longer embedded in the code during compilation!
I then got the error message: "The procedure 'NomDeProcedure ()' has been declared but not defined.

And if I don't use when declaring, "CompilerIf Defined (ProcessName, #PB_Procedure)", then I get the following error message:

"Line 182: ProcessName () is not a function, array, list, map or macro." :twisted:

Couldn't we have a new constant: "#PB_Declare" in order to test the declaration and the procedure clearly?

Thank you Fred for taking this request into account !!!

For now if anyone has a solution to distinguish between the declaration and the procedure itself, I am interested! :oops:

Thanks for reading me, I hope I was clear enough!



En Français pour tous les autres !

Une nouvelle constante: "#PB_Declare" pour l'instruction: Defined (Nom, Type) :?:

Bonjour a tous !

Dans un de mes projets, j'ai besoin de tester la présence de plusieurs procédures (cela fait suite a l'assemblage de plusieurs ligne de "XIncludeFile..." )!

Pour cela j'utilise deux fois :
"CompilerIf Defined( NomDeProcedure, #PB_Procedure)".
- un premier test lors de la déclaration : Declare....
- un deuxième test lors de la procédure elle même : Procedure...


Apparament si j'utilise :
"CompilerIf Defined( NomDeProcedure, #PB_Procedure)" pour tester la présence de la déclaration, alors la procédure n'est plus incorporer dans le code lors de la compilation !
J'ai alors le message d'erreur : "The procedure 'NomDeProcedure()' has been declared but not defined.


Et si je n'utilise pas lors de la déclaration, "CompilerIf Defined( NomDeProcedure, #PB_Procedure)", j'ai alors le message d'erreur suivant :

"Ligne 182: NomDeProcedure() is not a function, array, list, map or macro." :twisted:

Ne pourrait-on pas avoir une nouvelle constante : "#PB_Declare" afin de tester de façon bien distingue la déclaration et la procedure ?

Merci Fred de bien vouloir prendre on compte cette demande !!!

Pour l'heure si quelqu'un a une solution pour permettre de faire la distingtion entre la déclaration et la procedure elle-même, je suis preneur ! :oops:

Merci de m'avoir lu, j'espére avoir été assez clair !

Ulix.
BarryG
Addict
Addict
Posts: 1556
Joined: Thu Apr 18, 2019 8:17 am

Re: Please new constant: "#PB_Declare"

Post by BarryG »

I have no idea what problem you're trying to solve. Can you explain it better?
Ulix
User
User
Posts: 48
Joined: Wed Jan 23, 2008 12:45 pm
Location: France, Montpellier

Re: Please new constant: "#PB_Declare"

Post by Ulix »

Translation by google!

Hello BarryG

Thanks for reading my post

I need to know if a procedure has already been declared!
If I use the constant "#PB_Procedure" for the declaration
(in the 1st "CompilerIf Defined") then the Procedure does not
will not compile (in the 2nd "CompilerIf Defined")

A new constant "#PB_Declare" would be welcome in order to
do a test on the statement and so not to compromise
the 2nd test on the presence of the procedure in the 2nd
"CompilerIf Defined")

Here is the kind of code with the new constant for the test:
; CompilerIf Defined (BoutonDessin, ##PB_Declare) = #False

Code: Select all


; ============ Declarations
CompilerIf Defined (BoutonDessin, #PB_Procedure) = #False

    Debug "The declaration has not been made, I declare it!"
    Declare BoutonDessin()

CompileElse
    Debug "The declaration has already been made"
CompilerEndIf


;
; ============ Procedures
Procedure ProgressBar ()
Debug "Procedure affichage ProgresBarre"
EndProcedure
;Etc...
   
CompilerIf Defined (BoutonDessin, #PB_Procedure) = #False

    Debug "The procedure is not yet included in the program"
    Debug "It is added and therefore compiled!"

    Declare BoutonDessin()
        Debug "Procedure de Dessin du Bouton"
    EndProcedure

CompileElse
    Debug "The procedure is already included in the program"
    Debug "So it will be compiled!"
    Debug "ERROR! It is not compiled "
CompileEndIf


If anyone has a solution to help distinguish between
the declaration and the procedure itself, I am a taker!

thank you in advance :lol:



En français

J'ai besoin de savoir si une procedure a déja été déclaré !
Si j'utilise la constante "#PB_Procedure" pour la déclaration
(dans le 1er "CompilerIf Defined") alors la Procedure ne
sera pas compiler (dans le 2ème "CompilerIf Defined")

Une nouvelle constante "#PB_Declare" serait la bienvenue afin de
faire un test sur la déclaration et ainsi de ne pas compromettre
le 2ème test sur la présence de la procedure dans le 2ème
"CompilerIf Defined")
Voilà le genre code avec la nouvelle constante pour le test :
; CompilerIf Defined (BoutonDessin, ##PB_Declare) = #False

Code: Select all



;============Les Déclarations

CompilerIf Defined(BoutonDessin, #PB_Procedure) = #False        
   
   Debug "La déclaration n'a pas été faite, je la déclare !"
   Declare BoutonDessin()

CompilerElse                                                    
   Debug "La déclaration a déja été faite"
CompilerEndIf                                                   


;============Les procedures
Procedure ProgreBarre()
   Debug "Procedure affichage ProgresBarre"
   EndProcedure

CompilerIf Defined(BoutonDessin, #PB_Procedure) = #False          ;  

   Debug "La procedure n'est pas encore incluse dans le programme"
   Debug "Elle est ajouter et donc compilé !"

   Procedure BoutonDessin()
      Debug "Procedure de Dessin du Bouton"
   EndProcedure

CompilerElse
   Debug "La procedure est déja incluse dans le programme"
   Debug "Elle sera donc compilé !"
   Debug "ERREUR ! Elle n'est pas compilé"
CompilerEndIf

Si quelqu'un a une solution pour permettre de faire la distingtion entre
la déclaration et la procedure elle-même, je suis preneur !

Merci d'avance :lol:
cas
Enthusiast
Enthusiast
Posts: 596
Joined: Mon Nov 03, 2008 9:56 pm

Re: Please new constant: "#PB_Declare"

Post by cas »

The simplest solution i can think of is with a constants.

Code: Select all

; ============ Declarations
CompilerIf Not Defined (_BoutonDessin_declared, #PB_Constant)
  
  Debug "The declaration has not been made, I declare it!"
  Declare BoutonDessin()
  #_BoutonDessin_declared = 1
CompilerElse
  Debug "The declaration has already been made"
CompilerEndIf


;
; ============ Procedures
Procedure ProgressBar ()
  Debug "Procedure affichage ProgresBarre"
EndProcedure
;Etc...

CompilerIf Not Defined (_BoutonDessin_included, #PB_Constant)
  
  Debug "The procedure is not yet included in the program"
  Debug "It is added and therefore compiled!"
  
  Procedure BoutonDessin()
    Debug "Procedure de Dessin du Bouton"
  EndProcedure
  #_BoutonDessin_included = 1
CompilerElse
  Debug "The procedure is already included in the program"
  Debug "So it will be compiled!"
  Debug "ERROR! It is not compiled "
CompilerEndIf

BoutonDessin()
Ulix
User
User
Posts: 48
Joined: Wed Jan 23, 2008 12:45 pm
Location: France, Montpellier

Re: Please new constant: "#PB_Declare"

Post by Ulix »

Thanks to both of you, Cas and BarryG, for taking the time to look at my problem! :lol:

Yes it is a good solution to do my test on declarations and procedures!
I just have to add a constant for each declaration and procedure, this should not make more than ten more constant!
Thank you very much for this tip. :lol:

But I hope Fred will add the constant "#BP_Declare" for the "Defined" instruction.
There are already 14 constants, why not 15!
So I maintain my request for a new constant.
Fred I hope you read these lines ... Thanks in advance.
PeWa
New User
New User
Posts: 5
Joined: Fri Sep 06, 2019 8:25 pm

Re: Please new constant: "#PB_Declare"

Post by PeWa »

Hello,

look in the documentation under "residents", constants are saved in .res files.
You can compile your own .res files. I think more informations are in the PB SDK
Post Reply