DWScript includes a built-in code formatter that helps maintain consistent coding styles. The formatter parses the source code into a Code DOM (Document Object Model) and then regenerates the source code with standardized formatting.
The formatter (TdwsAutoFormat) can be configured with the following properties:
#9).The formatter applies several structural rules to ensure code readability:
Code blocks are automatically indented. This includes:
begin ... end blockscase ... end statementstry ... finally/except blocksrepeat ... until loopsThe formatter is designed to keep code compact while maintaining clarity. It does not force a new line after then, else, or do. This allows placing the begin on the same line, which is a supported and common style.
;var, const, type are clearly separated.Spaces are normalized around operators and punctuation:
:=,if (condition)).var i:Integer;for i:=1 to 10 do begin PrintLn(i);end;
var i : Integer;
for i := 1 to 10 do begin
PrintLn(i);
end; 1 2 3 4 5 6 7 8 9 10