<HTML><HEAD></HEAD>
<BODY dir=ltr>
<DIV dir=ltr>
<DIV style="FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: 12pt">
<DIV>Hello,</DIV>
<DIV> </DIV>
<DIV>I want to make sure that complete boolean evaluation for certain code
<BR>sections is on.</DIV>
<DIV> </DIV>
<DIV>However after the code section I want the "complete boolean evaluation"
<BR>compiler switch state back to what it was/the default.</DIV>
<DIV> </DIV>
<DIV>So I would like to write something like:</DIV>
<DIV> </DIV>
<DIV>{$if BOOLEVAL = ON}<BR> {$define
CompleteBooleanEvaluationWasOn}<BR>{$ifend}</DIV>
<DIV> </DIV>
<DIV>{$if BOOLEVAL = OFF}<BR> {$define
CompleteBooleanEvaluationWasOff}<BR>{$ifend}</DIV>
<DIV> </DIV>
<DIV>{$BOOLEVAL ON}<BR> ... code section ...<BR>{$if
CompleteBooleanEvaluationWasOn}<BR> {BOOLEVAL
ON}<BR>{$ifend}</DIV>
<DIV> </DIV>
<DIV>{$if CompleteBooleanEvaluationWasOff}<BR> {BOOLEVAL
OFF}<BR>{$ifend}</DIV>
<DIV> </DIV>
<DIV>So I would like the rest of the code to be un-effected by my compiler
switch <BR>change just to make sure that everything else compiles as
normal/default.</DIV>
<DIV> </DIV>
<DIV>However it either doesn't seem to be possible to write it like this or I am
<BR>not good enough at writing conditional compiler directives.</DIV>
<DIV> </DIV>
<DIV>Is it possible to solve it with compiler directives ?</DIV>
<DIV> </DIV>
<DIV>If not then perhaps Delphi Compiler needs a "default" directive like
so:</DIV>
<DIV> </DIV>
<DIV>{$BOOLEVAL DEFAULT}</DIV>
<DIV> </DIV>
<DIV>This would take the project options default value for this compiler
<BR>directive to solve the problem ! ;) =D</DIV>
<DIV> </DIV>
<DIV>I haven’t tried yet with Free Pascal, so what you guys think ? Possible or
not ?! </DIV>
<DIV>(I’m thinking not... so not even going to try it... but do surprise me if
you can !)</DIV>
<DIV> </DIV>
<DIV>
<DIV>To help you try it out here is a test program.</DIV>
<DIV></DIV>
<DIV>It's a little bit like an abortion... it's a little bit fucked up ! ;)
=D</DIV>
<DIV></DIV>
<DIV>But it's not to bad... if you do know how to solve it... then you can do it
! ;) =D</DIV>
<DIV> </DIV>
<DIV></DIV>
<DIV>// *** Begin of Test Program ***</DIV>
<DIV></DIV>
<DIV> </DIV>
<DIV>program TestProgram;</DIV>
<DIV> </DIV>
<DIV>{$APPTYPE CONSOLE}</DIV>
<DIV> </DIV>
<DIV>{</DIV>
<DIV> </DIV>
<DIV>Test complete boolean evaluation compiler switches to see if they<BR>are
unit/file width or per routine or per code section</DIV>
<DIV> </DIV>
<DIV>version 0.01 created on 14 june 2011 by Skybuck Flying</DIV>
<DIV> </DIV>
<DIV>Conclusion: it works per code section however there is a potential
problem:</DIV>
<DIV> </DIV>
<DIV>It might not be possible to return to the "default settings" ?!?</DIV>
<DIV> </DIV>
<DIV>For example once B+ is done all code below it will be effected ?!?<BR>B-
might then turn it off... but what if project default was on ?!?</DIV>
<DIV> </DIV>
<DIV>Perhaps it can be solved with $if or so... and some kind of
storage...</DIV>
<DIV> </DIV>
<DIV>}</DIV>
<DIV> </DIV>
<DIV>uses<BR> SysUtils;</DIV>
<DIV> </DIV>
<DIV>function Function1 : boolean;<BR>begin<BR>writeln('function1
called');<BR>result := true;<BR>end;</DIV>
<DIV> </DIV>
<DIV>function Function2 : boolean;<BR>begin<BR>writeln('function2
called');<BR>result := false;<BR>end;</DIV>
<DIV> </DIV>
<DIV>function Function3 : boolean;<BR>begin<BR>writeln('function3
called');<BR>result := false;<BR>end;</DIV>
<DIV> </DIV>
<DIV>// default result: function3 not called, pretty bad.<BR>procedure
TestRoutine1;<BR>var<BR>vResult : boolean;<BR>begin<BR>writeln('TestRoutine1
begin');<BR>vResult := true;<BR>vResult := vResult and Function1;<BR>vResult :=
vResult and Function2;<BR>vResult := vResult and
Function3;<BR>writeln('TestRoutine1 vResult: ', vResult
);<BR>writeln('TestRoutine1 end');<BR>end;</DIV>
<DIV> </DIV>
<DIV>procedure TestRoutine2;<BR>var<BR>vResult : boolean;<BR>begin</DIV>
<DIV> </DIV>
<DIV>{$BOOLEVAL ON}</DIV>
<DIV> </DIV>
<DIV>{$if (BOOLEVAL = ON)}<BR> {$define CompleteBooleanEvaluationWasOn
}<BR> writeln('it''s on');<BR>{$else}<BR> {$define
CompleteBooleanEvaluationWasOff}<BR> writeln('it''s
off');<BR>{$ifend}</DIV>
<DIV> </DIV>
<DIV>{$BOOLEVAL ON}<BR>writeln('TestRoutine2 begin1');<BR>vResult :=
true;<BR>vResult := vResult and Function1;<BR>vResult := vResult and
Function2;<BR>vResult := vResult and Function3;<BR>writeln('TestRoutine2
vResult: ', vResult );<BR>writeln('TestRoutine2 end1');<BR>{$BOOLEVAL OFF}</DIV>
<DIV> </DIV>
<DIV>writeln('TestRoutine2 begin2');<BR>vResult := true;<BR>vResult := vResult
and Function1;<BR>vResult := vResult and Function2; // off works... so it's code
specific ok nice. however what will happen outside of code... will it go to
default ?!?<BR>vResult := vResult and Function3;<BR>writeln('TestRoutine2
vResult: ', vResult );<BR>writeln('TestRoutine2 end2');</DIV>
<DIV> </DIV>
<DIV>{$if Defined(CompleteBooleanEvaluationWasOn)}<BR> writeln('turning it
on');<BR> {$BOOLEVAL ON}<BR>{$ifend}</DIV>
<DIV> </DIV>
<DIV>{$if Defined(CompleteBooleanEvaluationWasOff)}<BR> writeln('turning
it off');<BR> {$BOOLEVAL OFF}<BR>{$ifend}</DIV>
<DIV> </DIV>
<DIV>writeln('TestRoutine2 begin3');<BR>vResult := true;<BR>vResult := vResult
and Function1;<BR>vResult := vResult and Function2; // off works... so it's code
specific ok nice. however what will happen outside of code... will it go to
default ?!?<BR>vResult := vResult and Function3;<BR>writeln('TestRoutine2
vResult: ', vResult );<BR>writeln('TestRoutine2 end3');</DIV>
<DIV> </DIV>
<DIV>end;</DIV>
<DIV> </DIV>
<DIV>// little problem... booleval remains on... and now we don't know what the
default behaviour was ?!?<BR>// it's desireable to fall back to default
behaviour for the rest of the code ?!?<BR>procedure
TestRoutine3;<BR>var<BR>vResult : boolean;<BR>begin<BR>writeln('TestRoutine3
begin');<BR>vResult := true;<BR>vResult := vResult and Function1;<BR>vResult :=
vResult and Function2;<BR>vResult := vResult and
Function3;<BR>writeln('TestRoutine3 vResult: ', vResult
);<BR>writeln('TestRoutine3 end');<BR>end;</DIV>
<DIV> </DIV>
<DIV><BR>procedure Main;<BR>begin<BR>writeln('program started');</DIV>
<DIV> </DIV>
<DIV>TestRoutine1;<BR>TestRoutine2;<BR>TestRoutine3;</DIV>
<DIV> </DIV>
<DIV>writeln('program finished');<BR>end;</DIV>
<DIV> </DIV>
<DIV><BR>begin<BR> try<BR>Main;<BR> except<BR>on E: Exception
do<BR> Writeln(E.ClassName, ': ', E.Message);<BR>
end;<BR> ReadLn;<BR>end.<BR><BR>// *** End of Test Program ***</DIV>
<DIV></DIV></DIV>
<DIV>Bye,<BR> Skybuck. </DIV></DIV></DIV></BODY></HTML>