Skip to content

Implement the _TALLY system variable for the COUNT command - #2062

Merged
RobertvanderHulst merged 1 commit into
devfrom
feature/vfp-tally-count
Aug 20, 2026
Merged

Implement the _TALLY system variable for the COUNT command#2062
RobertvanderHulst merged 1 commit into
devfrom
feature/vfp-tally-count

Conversation

@Irwin1985

Copy link
Copy Markdown
Contributor

Fixes #2024, or at least the COUNT part of it.

Two things were broken. COUNT without the TO clause didn't even compile: the VO rule in dbcmd.xh expands to "<xvar> := 0", so leaving TO out gives you a naked := and an XS9002. And _TALLY was declared in SystemVariables.prg but nothing in the runtime ever wrote to it, so COUNT TO n gave you n = 2 and _TALLY = 0.

Added three COUNT rules plus a __VfpCount() helper in Commands.prg. The helper just wraps DbEval(), same as the VO rule did, but counts inside and stores the result in _TALLY.

@RobertvanderHulst

Copy link
Copy Markdown
Member

Irwin,
I am considering to add a setting to the runtime, where dbeval() stores the # of records processed in it's last run.
Something similar to the field where the error code for the low level file operations is stored.
That can then be used to assign _tally but is also available for other code.
I cannot assign to _tally directly since that field is inside the vfp assembly.
I will create a local inside the dbeval code and assign the setting after dbeval() finishes.
What do you think of this?

@RobertvanderHulst
RobertvanderHulst merged commit 496bd9a into dev Aug 20, 2026
1 check passed
@Irwin1985

Copy link
Copy Markdown
Contributor Author

Hi Robert,

Sounds good to me. My helper only counts for COUNT, every other command would need its own. One thing I hit while checking this against VFP 9 is that _TALLY is the records affected, not the ones visited. With 5 records and 1 deleted, RECALL ALL reports 1, but our RECALL goes through DbEval with scope ALL, so a counter in there would say 5. Might need special casing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants