DWScript promotes a consistent coding style through its built-in rules engine (Gabelou). Following these guidelines ensures that your code remains readable and idiomatic.
procedure DoWork(itemCount : Integer);var userName := 'John';function CalculateTotal : Float;type TUserRecord = record ... end;property FullName : String ...| Category | Rule | Example |
|---|---|---|
| Private Fields | Start with F followed by PascalCase |
FInternalValue |
| Class Variables | Start with v followed by PascalCase |
vGlobalCounter |
| Constants | Start with c + PascalCase OR ALL_CAPS |
cDefaultPort, MAX_RETRY |
| Exceptions | Type names starting with E should be Exception classes |
EValidationError |
| Attributes | Should end with Attribute and NOT have a T prefix |
WebMethodAttribute |
Consistency is key to a healthy codebase. The following rules are promoted by the formatter:
begin on the same line as then, else, or do is encouraged to reduce vertical space.#' or #" ), it is recommended to place the closing delimiter on a new line. This improves readability and makes it easier to append content.:= and after commas ,.You can use the TdwsAutoFormat class in your own tools to programmatically clean up DWScript source code according to these rules.