Search code examples
delphidwscript

DWScript uses clause


I've hit a wall with DWScript trying to "use" other units example:

uses utils, qusers;
Syntax Error: Unknown unit "utils" [line: 3, column: 20]

any help would be highly appreciated.

Additional info: I also add to Script.Config.ScriptPaths the location of files, for example: "C:\myscripts"

Additional info2: the purpose of "uses" usage was that "$INCLUDE" or "$I" had an issue when:
unit1.dws includes unit2.dws
unit3.dws includes unit3.dws and unit1.dws


Solution

  • On current SVN version and beyond, you can use $INCLUDE_ONCE, which will include a file only if it hasn't been already included (it's case-sensitive).

    For older versions, you can use conditional compilations, like in C header files:

    {$IFNDEF SOME_FILE}
    {$DEFINE SOME_FILE}
    
    ... the file ...
    
    {$ENDIF}
    

    Edit: As of august 2011, units are supported, they must be used from a main script or from another unit. See tests\BuildScripts for sample code.