Delphi-RAG-Lint

drag-lint help

Field repository: generated calc fields

Since: 1.61.0-alpha

Writes a dataset's stored calculated-field bodies into one volatile OnCalcFields region, in dependency order.

Read this when the OnCalcFields code of a form should come from the field repository. The plan is shown first (a dry run); a calc cycle or a shared or missing handler is refused, and a region you edited by hand is replaced only after a backup is kept.

How to run it

drag-lint repo gen-calc --dfm <file.dfm> [--unit <file.pas>] [--dataset <Name>] [--apply | --select <file>] [--dry-run] [--json] (--repo <file> | --project <project file>)

Full flag list: repo in the CLI reference.

Flags

FlagArgumentMeaningDefault
--dfm<file.dfm>
--unit<file.pas>
--dataset<Name>
--select<file>
--repo<file>
--project<project file>
--apply
--dry-run
--json

Where to click

No IDE surface: this feature runs from the CLI (see How to run it).

Details

repo gen-calc writes the stored calculated-field bodies (CALC_BODY) of a form's dataset into the handler the DFM assigns to OnCalcFields. It is a dry run until --apply; --dry-run wins over --apply.

drag-lint repo gen-calc --dfm <file.dfm> [--unit <file.pas>] [--dataset <Name>] [--apply | --select <file>] [--dry-run] [--json] (repository via --repo or --project).

The region

procedure TdmCalc.memLinesCalcFields(DataSet: TDataSet);
begin
  {$REGION 'DLFR memLines.OnCalcFields volatile'}
  ...bodies in dependency order...
  {$ENDREGION 'DLFR memLines.OnCalcFields'}
end;
  • One region at the END of the handler, volatile: no hash, so it is regenerated on every run.
  • Bodies are ordered by dependency (a field read by another is written first), whatever the DFM order; macros are expanded.
  • A hashed region written by gen-handlers is converted (note converted: the hashed region is volatile now); hand-edited lines in it are replaced and the backup keeps them.
  • gen-handlers skips a handler that holds a volatile region (a volatile region holds this code: repo gen-calc writes it).

Plan, selection, output

Text: # plan <16 hex>, then per region [id] insert|update <Dataset>.OnCalcFields, unchanged, skipped or REFUSED, with note: lines. --select <file> writes only the ids listed under the file's # plan <id> line; a plan of another run is refused. --json: verb, plan, regions[] (id, region, target, state, reason, notes), mode, applied, written, backups.

Exit code: 0 ok; 1 a refused region (calc cycle A -> B -> A, shared or missing handler), a missing repository, DFM or unit, a --select of another plan, a write failure; 2 usage (no --dfm, --select file missing, without a plan line or with an unknown id). A written unit keeps a backup.


All features | CLI reference | IDE menus