In Foxpro either of the following is valid:
COUNT FOR state="CA" TO statecount
COUNT TO statecount FOR state="CA"
The X# compiler currently only allows the second construction in which the variable is named before the condition. I haven't tested it, but I wonder whether this is a general issue that might affect commands similar to COUNT.
placement of condition in count command
- kevclark64
- Posts: 127
- Joined: Thu Aug 15, 2019 7:30 pm
- Location: USA
placement of condition in count command
Kevin,
The X# compiler allows to freely change the order of optional clauses in user defined commands.
The COUNT command is declared as
As you can see: the TO <var> is not optional (not between brackets) and therefore not optional.
I will see if I can tweak the command to allow TO <var> to be at the end of the command.
Making the TO <var> clause optional would technically work and allow to swap the TO and FOR clauses.
But if TO is missing then it would need to generate a compiler error.
Robert
Edit:
Maybe we can add a special notation to indicate that the "optional" clause is not really optional but can be moved around freely.
Something like this:
where the ^ character would tell the preprocessor that the TO <var> clause has to be matched.
The X# compiler allows to freely change the order of optional clauses in user defined commands.
The COUNT command is declared as
Code: Select all
#command COUNT TO <var> ;
[FOR <for>] ;
[WHILE <while>] ;
[NEXT <next>] ;
[RECORD <rec>] ;
[<rest:REST>] ;
[ALL] ;
;
=> <var> := 0 ;
; DbEval( ;
{|| <var> := <var> + 1}, ;
<{for}>, <{while}>, <next>, <rec>, <.rest.> ;
)
I will see if I can tweak the command to allow TO <var> to be at the end of the command.
Making the TO <var> clause optional would technically work and allow to swap the TO and FOR clauses.
But if TO is missing then it would need to generate a compiler error.
Robert
Edit:
Maybe we can add a special notation to indicate that the "optional" clause is not really optional but can be moved around freely.
Something like this:
Code: Select all
#command COUNT [^TO <var> ] ;
[FOR <for>] ;
etc
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu
- lumberjack
- Posts: 727
- Joined: Fri Sep 25, 2015 3:11 pm
- Location: South Africa
placement of condition in count command
Robert,
I created quickly a new count command and it seems according to the .ppo file it creates the correct output.robert wrote:Kevin,
The X# compiler allows to freely change the order of optional clauses in user defined commands.
Code: Select all
#command COUNT ;
[FOR <for>] ;
[WHILE <while>] ;
[NEXT <next>] ;
[RECORD <rec>] ;
[<rest:REST>] ;
[ALL] ;
TO <var> ; // Note where the TO <var> is positioned
=> <var> := 0 ;
; DbEval( ;
{|| <var> := <var> + 1}, ;
<{for}>, <{while}>, <next>, <rec>, <.rest.> ;
)
______________________
Johan Nel
Boshof, South Africa
Johan Nel
Boshof, South Africa
placement of condition in count command
Johan,
Yes that works. And it matches both
and
Why did I not think of that myself?
I will adjust the UDC in our header file
Robert
Yes that works. And it matches both
Code: Select all
COUNT TO Var FOR SomeCondition
Code: Select all
COUNT FOR SomeCondition TO Var
I will adjust the UDC in our header file
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu
placement of condition in count command
I use the (new) UDC Tester for this. That works very well !Robert,
I created quickly a new count command and it seems according to the .ppo file it creates the correct output.
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu
- lumberjack
- Posts: 727
- Joined: Fri Sep 25, 2015 3:11 pm
- Location: South Africa
placement of condition in count command
Robert,
Have downloaded the new version and will next week install and see how the next article in the Data-driven series progress.
I have to apologize was not focusing on computer work the last couple of months due to my eyes, but I am feeling ready to start again.robert wrote: I use the (new) UDC Tester for this. That works very well !
Have downloaded the new version and will next week install and see how the next article in the Data-driven series progress.
______________________
Johan Nel
Boshof, South Africa
Johan Nel
Boshof, South Africa