Re: [fpc-pascal] Illegal counter variable?

2019-09-11 Thread Christo Crause
On Wed, Sep 11, 2019 at 7:06 AM Ralf Quint  wrote:

> On 9/10/2019 4:26 PM, wkitt...@windstream.net wrote:
> > On 9/9/19 10:11 AM, James Richters wrote:
> >> Pascal doesn't have things like step...
> >
> > hunh??? i don't think that's right but i'm just catching up after
> > several 10+ hours days of $job...
> >
> > i know that i've written code in the past that did use something to
> > step X numbers per run through the look and it did not involved
> > manually incrementing the loop var...
> >
> >
> I am not aware of any Pascal implementation that does have a STEP
> parameter for FOR loops, and I am programming in Pascal at least as long
> as you... ;-)
>

FPC documentation:
https://www.freepascal.org/docs-html/ref/refsu58.html#x164-18600013.2.4 -
at least FPC doesn't allow specifying an increment size.  Several other
languages do allow specifying an increment (nice list of for loop
constructs with specified increment in various languages:
https://www.rosettacode.org/wiki/Loops/For_with_a_specified_step).  Modula-2
or Oberon-2 code snippets could perhaps be mistaken for Pascal through the
mists of time.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Illegal counter variable?

2019-09-11 Thread Sven Barth via fpc-pascal
Christo Crause  schrieb am Mi., 11. Sep. 2019,
09:54:

>
> On Wed, Sep 11, 2019 at 7:06 AM Ralf Quint  wrote:
>
>> On 9/10/2019 4:26 PM, wkitt...@windstream.net wrote:
>> > On 9/9/19 10:11 AM, James Richters wrote:
>> >> Pascal doesn't have things like step...
>> >
>> > hunh??? i don't think that's right but i'm just catching up after
>> > several 10+ hours days of $job...
>> >
>> > i know that i've written code in the past that did use something to
>> > step X numbers per run through the look and it did not involved
>> > manually incrementing the loop var...
>> >
>> >
>> I am not aware of any Pascal implementation that does have a STEP
>> parameter for FOR loops, and I am programming in Pascal at least as long
>> as you... ;-)
>>
>
> FPC documentation:
> https://www.freepascal.org/docs-html/ref/refsu58.html#x164-18600013.2.4 -
> at least FPC doesn't allow specifying an increment size.  Several other
> languages do allow specifying an increment (nice list of for loop
> constructs with specified increment in various languages:
> https://www.rosettacode.org/wiki/Loops/For_with_a_specified_step).  Modula-2
> or Oberon-2 code snippets could perhaps be mistaken for Pascal through the
> mists of time.
>

Well, we do have a patch for "for ... (down)to ... by" support:
https://bugs.freepascal.org/view.php?id=25549

Regards,
Sven

>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Illegal counter variable?

2019-09-11 Thread Martin Wynne
I am not aware of any Pascal implementation that does have a STEP 
parameter for FOR loops


If step is wanted, it's easy enough:

For n:=a to b Do
  Begin
if n Mod step <> 0 then Continue;
...


Martin.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Illegal counter variable?

2019-09-11 Thread Martin Wynne

If step is wanted, it's easy enough:

For n:=a to b Do
   Begin
     if n Mod step <> 0 then Continue;
     ...



p.s. make that

  if (n-a) Mod step <> 0 then Continue;

for cases where a is not a multiple of step.

Martin.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Illegal counter variable?

2019-09-11 Thread James Richters
How do you get ‘By’ to work?   I have downto working but if I try ‘By’ I get

 

Fatal: Syntax error, "DO" expected but "identifier BY" found

 

If FPC is going to support downto and by, why not also support changing the 
control variable when not in {$Mode TP} as well, and just make a note that 
doing so may not be compatible with other pascal compilers.. but who cares 
anyway FPC is better than all the others anyway 😊 

 

>Well, we do have a patch for "for ... (down)to ... by" support: 
>https://bugs.freepascal.org/view.php?id=25549

 

James

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Illegal counter variable?

2019-09-11 Thread James Richters
I don't know what the syntax would be if it did have a way to do a step

https://wiki.lazarus.freepascal.org/FOR..DO

"In Pascal, the for loop can only count in increments (steps) of 1"

James

-Original Message-
From: fpc-pascal  On Behalf Of 
wkitt...@windstream.net
Sent: Tuesday, September 10, 2019 7:26 PM
To: fpc-pascal@lists.freepascal.org
Subject: Re: [fpc-pascal] Illegal counter variable?

On 9/9/19 10:11 AM, James Richters wrote:
> Pascal doesn't have things like step...

hunh??? i don't think that's right but i'm just catching up after several 10+ 
hours days of $job...

i know that i've written code in the past that did use something to step X 
numbers per run through the look and it did not involved manually incrementing 
the loop var...


--
  NOTE: No off-list assistance is given without prior approval.
*Please keep mailing list traffic on the list unless*
*a signed and pre-paid contract is in effect with us.* 
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Illegal counter variable?

2019-09-11 Thread Sven Barth via fpc-pascal
James Richters  schrieb am Mi., 11. Sep.
2019, 16:24:

> How do you get ‘By’ to work?   I have downto working but if I try ‘By’ I
> get
>
>
>
> Fatal: Syntax error, "DO" expected but "identifier BY" found
>

Did you see anywhere that said that this bug report was resolved and the
patch integrated into trunk?


>
> If FPC is going to support downto and by, why not also support changing
> the control variable when not in {$Mode TP} as well, and just make a note
> that doing so may not be compatible with other pascal compilers.. but who
> cares anyway FPC is better than all the others anyway 😊
>

There is no interest in lifting that restriction. Out of the dialects that
FPC supports TP is the only one that does not. Even Wirth advised against
allowing it.

Also FPC already supports downto. Just like TP and Delphi do...

Regards,
Sven

>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Illegal counter variable?

2019-09-11 Thread scoxb...@shaw.ca
Yes, off topic. The initial poster's code had the loop variable declared as an initialized constant. Not as a true variable. No FPC in hand, I can't test if setting 'assignable typed constants = true' would permit the use of an initialized typed constant or not. Sent from my Huawei phone Original Message Subject: Re: [fpc-pascal] Illegal counter variable?From: DougC To: FPC-Pascal users discussions CC: The last messages have wandered off topic somewhat. Can we stick to the original request, which was why the handling of the two declarations differed?Doug C.___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Illegal counter variable?

2019-09-11 Thread DougC
Actually, the original code used two VARs, not typed CONST. One VAR was 
initialized and one was not. I think this is a bug and should be fixed.


As Jonas already pointed out:

"var i : longint = 0;" is internally handled using the same code path as 

"const i : longint = 0", and typed constants cannot be used as counter 

variables. This is indeed probably a bug.




 On Wed, 11 Sep 2019 12:40:57 -0400   wrote 


Yes, off topic. The initial poster's code had the loop variable declared as an 
initialized constant. Not as a true variable. No FPC in hand, I can't test if 
setting 'assignable typed constants = true' would permit the use of an 
initialized typed constant or not. ___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Illegal counter variable?

2019-09-11 Thread James Richters
I reported it here:

https://bugs.freepascal.org/view.php?id=36065

 

James

 

>Actually, the original code used two VARs, not typed CONST. One VAR was 
>initialized and one was not. I think this is a bug and should be fixed.


>As Jonas already pointed out:

 

>"var i : longint = 0;" is internally handled using the same code path as 

>"const i : longint = 0", and typed constants cannot be used as counter 

>variables. This is indeed probably a bug.

 

> On Wed, 11 Sep 2019 12:40:57 -0400  > wrote 

 

>Yes, off topic. 

>The initial poster's code had the loop variable declared as an initialized 
>constant. Not as a true variable. No FPC in hand, I can't test if setting 
>'assignable typed >constants = true' would permit the use of an initialized 
>typed constant or not. 

 

 

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Illegal counter variable?

2019-09-11 Thread wkitty42

On 9/11/19 1:06 AM, Ralf Quint wrote:

On 9/10/2019 4:26 PM, wkitt...@windstream.net wrote:

On 9/9/19 10:11 AM, James Richters wrote:

Pascal doesn't have things like step...


hunh??? i don't think that's right but i'm just catching up after several 10+ 
hours days of $job...


i know that i've written code in the past that did use something to step X 
numbers per run through the look and it did not involved manually incrementing 
the loop var...



I am not aware of any Pascal implementation that does have a STEP parameter for 
FOR loops, and I am programming in Pascal at least as long as you... ;-)


i may be thinking of a while loop... am in the middle of 10+ hour days at the 
moment... first since May of this year... at least now i don't have to go to the 
food bank for eats... maybe this weekend i can scan my old TP6 code and find 
what i'm remembering?? i dunno...


--
 NOTE: No off-list assistance is given without prior approval.
   *Please keep mailing list traffic on the list unless*
   *a signed and pre-paid contract is in effect with us.*
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal