DWScript conditional compilation directives

Current SVN version of Delphi Web Script now supports the following directives (all new but include and filter):

  • $I, $INCLUDE, $F, $FILTER: include specified file (which can be on disk or come through the virtual file system), the FILTER variants will include the file after filtering it.
    {$INCLUDE 'mysource.inc'}
  • $DEFINE, $UNDEF: define and un-define a conditional.
  • $IFDEF, $IFNDEF, $ELSE, $ENDIF: allow specifying conditionally compiled blocks.
    ...special code here...
    ...not so special code here...
  • $HINT, $WARNING, $ERROR, $FATAL: output a custom compiler hint, warning or error message.
    {$HINT 'That is not wise...'}
    {$WARNING 'You should NOT be doing that!'}
    {$ERROR 'Do not do that. Period.'}
    {$FATAL 'After that, I won''t even try to compile your code!'}

Conditionals are case-insensitive names, conditional blocks can be nested.
Default conditionals when compiling can be adjusted via a new property in the TdwsConfiguration.

edit: added $FATAL

5 thoughts on “DWScript conditional compilation directives

  1. Hi Eric,

    i have an old project using DWS2 and i tried to switch to your new implementation.
    Unfornately i cannot compile it with D7. Do you plan to supporting it?

    Best regards
    Dirk Carstensen

  2. No, as I don’t use it anymore and haven’t for a while. If a D7 version it’ll have to be supported by someone else.
    If at the moment it could be somewhat still reasonnable to make the code compatible, modern constructs (like generics) will be made use of, and that’ll make things quite a bit more complex however.

Comments are closed.