Page 1 of 1
Program in correct switches
Posted: Thu Sep 03, 2015 4:54 pm
by blueb
Instead of always reminding the user to apply a certain compiler switch:
CompilerIf #PB_Compiler_Thread = 0
MessageRequester("Warning","Without Threadsafe... this won't work!")
CompilerEndIf
If the program needs a switch to run properly, why can't the programmer just write:
#PB_Compiler_Thread = 1
or...
SetSwitch(#PB_Compiler_Thread, 1)
Re: Program in correct switches
Posted: Thu Sep 03, 2015 5:55 pm
by GPI
That will not solve your problem, but maybe this would be a better solution.
Code: Select all
CompilerIf #PB_Compiler_Thread=0
(0/1) "please activate ThreadSave in the Compiler Options"
CompilerEndIf
When the flag is not activated, the compiler stops in the line with a Syntax error, otherwise it compile correctly.
Maybe the Problem is,that when the "Switch" is not at the begin of you SoureCode, it must stop compiling and start from the beginning. Also maybe a Problem, when you activate and deactivate the switch at diffrent position in your source code.
Re: Program in correct switches
Posted: Thu Sep 03, 2015 6:22 pm
by kenmo
There is CompilerError for that purpose:
Code: Select all
CompilerIf (Not #PB_Compiler_Unicode)
CompilerError "Please compile in Unicode mode"
CompilerEndIf
blueb, this would be a tricky change, I think, because compile switches like /Unicode are currently passed to the pbcompiler commandline, so it "knows" all the switches before it even starts loading/parsing through your code.
Re: Program in correct switches
Posted: Thu Sep 03, 2015 6:38 pm
by blueb
Thanks kenmo.
It was only a small request... nothing important.
You're right, the compiler needs to know 'in advance' to reading and executing the code.
Basically, I was thinking that when a person places some code on the forum for other users...
If the compiler was not in the desired mode, it could be done in the code itself, rather than
forcing the user to activate the switches manually.