Hexor,
If you look at the ASM for some code you'll notice that the ASM makes no reference to any Constant. Not one.
This is because all constants are resolved at compile time. If you use the constant #Five as 5 then in the compiled code every instance of #Five will have been replaced with 5.
Take a look at you're code:
Code: Select all
l$ = ProgramParameter()
If l$ = "-no"
#Debugging = #False
Else
#Debugging = #True
EndIf
At compile time how can the compiler possibly know the value of l$? It cannot, this variable is resolved at Runtime.
Lets examine some possible solutions.
Firstly, your own suggestion:
Always the first declared value will be taken and any following declaration will be ignored.
In this instance #Debugging will always be false because that is the first occurance of #Debugging in the text. Regardless of the command paramaters the #Debugging will always be #False.
This is clearly not what you wanted. The difference would be that now the fault is silent. You will have no warning that you're debugging mode does not work until you have deployed your executable and you really need it to fix a problem while you're customer is breathing down you're neck.
Instead we could have Constants evaluated at runtime. This will slow down you're code because now instead of 'mov eax, 5' you are using 'mov eax, [#lbl_five].
If you want to have conditional constants then use compiler directives:
http://www.purebasic.com/documentation/ ... tives.html
If you want values that are evaluated at Runtime, use variables.