----- Original Message ----- From: "Chris Veale" <[EMAIL PROTECTED]> Sent: Friday, December 06, 2002 11:33 AM Subject: [DUG]:changing compile conditions at runtime...
> Hi > > I want to implement something like a passcode that when entered allows the > user to do something different than a user without that passcode. I have > all the functionality already in the code with compile conditions but from > all the help Ive looked through, I cant change this on the fly - it takes a > full recompile. > > Is there any way of allowing this change at runtime using compile conditions > or am I going to have to rebuild the functionality with if statements? The compile-time conditions alter the code that is produced, so any condition that isn't met effectively comments out the code it encloses. If you want to offer variable functionality dependant on a code, user level, etc. then you'll have to write the logic for it into your code. How to go about it depends on a variety of things, including how much difference there is between one level and another. If you have only two states that differ only in a few lines of code, then a conditional statement is probably sufficient. For a more complex difference (additions to the interface, completely new functionality, etc), and if you use a reasonably OO design, you could derive a higher-functionality object from the standard interface, add whatever you need, then instanciate the one that fits the current user level. Remember KISS though. If you don't need to change much, do it the simplest way you can - which usually means conditionals in your code. Final thought: if you want the REALLY complex way, how about implementing the enhanced functionality in a BPL, and only distribute that to people who need it. Same as deriving from a common object, but with added security in that people who don't have the BPL can't get access to the extra functions, no matter how they try to hack the program. -- Corey Murtagh The Electric Monk "Quidquid latine dictum sit, altum viditur." --------------------------------------------------------------------------- New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] Website: http://www.delphi.org.nz To UnSub, send email to: [EMAIL PROTECTED] with body of "unsubscribe delphi" Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/