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

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

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

Re: [fpc-pascal] Illegal counter variable?

2019-09-11 Thread scoxb...@shaw.ca
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

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

Re: [fpc-pascal] Illegal counter variable?

2019-09-11 Thread James Richters
t: 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

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

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 -

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 -

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

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

Re: [fpc-pascal] Illegal counter variable?

2019-09-10 Thread Ralf Quint
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

Re: [fpc-pascal] Illegal counter variable?

2019-09-10 Thread wkitty42
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

Re: [fpc-pascal] Illegal counter variable?

2019-09-10 Thread James Richters
-pascal On Behalf Of Markus Greim Sent: Monday, September 9, 2019 1:32 PM To: FPC-Pascal users discussions Subject: Re: [fpc-pascal] Illegal counter variable? James, not every body is using a GHz machine. I am , for example, programming a 80186 in an embedded system with very limited

Re: [fpc-pascal] Illegal counter variable?

2019-09-10 Thread Markus Greim
s, and use the more efficient optimized code when it detects that it is able to use it? James -Original Message- From: fpc-pascal On Behalf Of Bernd Oppolzer Sent: Monday, September 9, 2019 10:46 AM To: FPC-Pascal users discussions Subject: Re: [fpc-pascal] Illegal counter variable? Am 09.09.

Re: [fpc-pascal] Illegal counter variable?

2019-09-10 Thread Markus Greim
AFAIK these is the standard behavior since the first PASCAL versions. We must not change it. It prevents a lot of side effects, and PASCAL is NOT C without brackets! Use while or repeat instead! >From Niklaus Wirths last 2004 Oberon manual:

Re: [fpc-pascal] Illegal counter variable?

2019-09-09 Thread James Richters
Cc: Mattias Gaertner Subject: Re: [fpc-pascal] Illegal counter variable? On Mon, 9 Sep 2019 19:27:49 +0200 Bart wrote: > On Mon, Sep 9, 2019 at 4:54 PM Jonas Maebe > wrote: > > > "var i : longint = 0;" is internally handled using the same code > > path as &qu

Re: [fpc-pascal] Illegal counter variable?

2019-09-09 Thread Mattias Gaertner via fpc-pascal
On Mon, 9 Sep 2019 19:27:49 +0200 Bart wrote: > On Mon, Sep 9, 2019 at 4:54 PM Jonas Maebe > wrote: > > > "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

Re: [fpc-pascal] Illegal counter variable?

2019-09-09 Thread Bart
On Mon, Sep 9, 2019 at 4:54 PM Jonas Maebe wrote: > "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. D7 does not allow this for global variables: "for

Re: [fpc-pascal] Illegal counter variable?

2019-09-09 Thread James Richters
To: FPC-Pascal users discussions Subject: Re: [fpc-pascal] Illegal counter variable? Am 09.09.2019 um 16:11 schrieb James Richters: > I just don't see why having the limitation, there is no technical > reason that the for loop couldn't change that I can see.. especially since it > works i

Re: [fpc-pascal] Illegal counter variable?

2019-09-09 Thread Martin Wynne
On 09/09/2019 15:11, James Richters wrote: If (I>86) And (I<95) then Continue; What does continue do exactly? Loop back to the beginning of the for loop right away? Hi James, Yes in effect -- it jumps forward to the test at the end of a loop. Very useful. See:

Re: [fpc-pascal] Illegal counter variable?

2019-09-09 Thread Jonas Maebe
On 2019-09-09 11:30, James Richters wrote: Can someone please tell me why this happens? Var I : Longint = 0; Begin For I := 1 to 6 Do Writeln(I); End. This gives me : initialize.pas(4,5) Error: Illegal counter variable initialize.pas(6,4) Fatal: There were 1 errors compiling module,

Re: [fpc-pascal] Illegal counter variable?

2019-09-09 Thread Bernd Oppolzer
Am 09.09.2019 um 16:11 schrieb James Richters: I just don't see why having the limitation, there is no technical reason that the for loop couldn't change that I can see.. especially since it works in TP mode. The original reason why some Pascal implementations had this limitation: for

Re: [fpc-pascal] Illegal counter variable?

2019-09-09 Thread James Richters
: [fpc-pascal] Illegal counter variable? On 09/09/2019 13:38, James Richters wrote: > Var > I:Byte; > Begin >I:=57; >For I := I to 100 do > Begin > If I=87 then >I:=95; > Write(I,' '); > End; > End. Why not: Var

Re: [fpc-pascal] Illegal counter variable?

2019-09-09 Thread DougC
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

Re: [fpc-pascal] Illegal counter variable?

2019-09-09 Thread Martin Wynne
On 09/09/2019 13:38, James Richters wrote: Var I:Byte; Begin I:=57; For I := I to 100 do Begin If I=87 then I:=95; Write(I,' '); End; End. Why not: Var I:Byte; Begin I:=57; For I := I to 100 do Begin If (I>86) And (I<95)

Re: [fpc-pascal] Illegal counter variable?

2019-09-09 Thread James Richters
>That page only talks about assigning the loop var *inside* the loop, which is >forbidden. You can re-assign the loop variable if you are in {$Mode TP} it works perfectly fine to re-assign the for variable inside the loop, and I use that extensively, I have TP units specifically so I can do

Re: [fpc-pascal] Illegal counter variable?

2019-09-09 Thread James Richters
@lists.freepascal.org Cc: Mattias Gaertner Subject: Re: [fpc-pascal] Illegal counter variable? On Mon, 9 Sep 2019 11:44:05 +0200 SPRL AFOR wrote: > Hi. > > Index variable can neither be initialized nor computed. Read > https://wiki.lazarus.freepascal.org/FOR..DO That page only talks abo

Re: [fpc-pascal] Illegal counter variable?

2019-09-09 Thread Mattias Gaertner via fpc-pascal
On Mon, 9 Sep 2019 11:44:05 +0200 SPRL AFOR wrote: > Hi. > > Index variable can neither be initialized nor computed. Read > https://wiki.lazarus.freepascal.org/FOR..DO That page only talks about assigning the loop var *inside* the loop, which is forbidden. James question is about the

Re: [fpc-pascal] Illegal counter variable?

2019-09-09 Thread SPRL AFOR
Hi. Index variable can neither be initialized nor computed. Read https://wiki.lazarus.freepascal.org/FOR..DO Antonio Le 09/09/2019 à 11:30, James Richters a écrit : Can someone please tell me why this happens? Var I : Longint = 0; Begin For I := 1 to 6 Do Writeln(I); End. This