3

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

1 Answers1

2

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.

Eric Grange
  • 5,931
  • 1
  • 39
  • 61
  • @Eric: I've come across difficulty using 'uses' and nominating a simple file. Is this supported in the latest DWS? I've found that I can include a file ok, but not as a traditional unit format. – Brian Frost Aug 22 '11 at 15:25
  • 1
    unit support requires the very latest svn, see test\BuildScripts for sample code. You can "uses" a unit from a main script, or from a unit. A unit is composed as in Delphi of a "unit unitname;" at the top, followed by an interface, implementation, and terminated by an optional "end.", there is no initialization/finalization. Note that you can't compile an isolated unit, you must compile it from a main script. – Eric Grange Aug 23 '11 at 08:16
  • @Eric: Perfect, thanks. What I was missing was understanding how to expose the unit source to the compiler. When I discovered the event 'OnNeedUnit' and filled this in, it all just works. Many Thanks. – Brian Frost Aug 23 '11 at 14:08