[comp.lang.pascal] Re^2: Control variables in FOR

ipis@cdp.UUCP (02/07/89)

I've had the same problem with INVALID CONTROL VARIABLE using HP
Pascal on the Hp3000 at school.  I think it doesn't follow along the
scope rules for standard pascal.  If you declare I as local to the
procedure, it works.
--andy Perrin

bobd@ihf1.UUCP (Bob Dietrich) (02/11/89)

In article <134300002@cdp> ipis@cdp.UUCP writes:
>
>I've had the same problem with INVALID CONTROL VARIABLE using HP
>Pascal on the Hp3000 at school.  I think it doesn't follow along the
>scope rules for standard pascal.  If you declare I as local to the
>procedure, it works.
>--andy Perrin

Sorry, but HP3000 Pascal is correct in this regard. The control variable for
a for-statement must be declared local to the block of the procedure,
function, or program closest containing the for-statement.

There are many compilers that predate the Pascal standard, and therefore do
not enforce this restriction. Sometimes it's because no one has bought an
updated compiler; sometimes it's because the vendor hasn't issued an update;
and sometimes it's because the vendor shows no intention of conforming to
standards (like Borland and Turbo Pascal).

usenet:	uunet!littlei!intelhf!ihf1!bobd		Bob Dietrich
  or	tektronix!ogccse!omepd!ihf1!bobd	Intel Corp., Hillsboro, Oregon
  or	tektronix!psu-cs!omepd!ihf1!bobd	(503) 696-2092

ipis@cdp.UUCP (02/13/89)

No, I just wasn't aware of that restriction on global variables in FOR
loops.  Thankx.
--andy 

leonard@bucket.UUCP (Leonard Erickson) (02/13/89)

In article <518@ihf1.UUCP> bobd@ihf1.UUCP (Bob Dietrich) writes:
<Sorry, but HP3000 Pascal is correct in this regard. The control variable for
<a for-statement must be declared local to the block of the procedure,
<function, or program closest containing the for-statement.
<
<There are many compilers that predate the Pascal standard, and therefore do
<not enforce this restriction. Sometimes it's because no one has bought an
<updated compiler; sometimes it's because the vendor hasn't issued an update;
<and sometimes it's because the vendor shows no intention of conforming to
<standards (like Borland and Turbo Pascal).

Sorry, but while Borland isn't 100% compliant, they are increasing their
compliance. I've ported code from v3 to v4 and now to v5. I've had to "fix"
non-compliant areas. 

Versions 5 *does* required that loop control variables be local. I had to 
change a number of global variables to local ones to make the code work.
(Not my fault, I didn't write the original code, and the guy who did is
normally working with COBOL and it shows!)

-- 
Leonard Erickson		...!tektronix!reed!percival!bucket!leonard
CIS: [70465,203]
"I'm all in favor of keeping dangerous weapons out of the hands of fools.
Let's start with typewriters." -- Solomon Short

bobd@ihf1.UUCP (Bob Dietrich) (02/16/89)

In article <1260@bucket.UUCP> leonard@bucket.UUCP (Leonard Erickson) writes:
>In article <518@ihf1.UUCP> bobd@ihf1.UUCP (Bob Dietrich) writes:
>>There are many compilers that predate the Pascal standard, and therefore do
>>not enforce this restriction. [...]
>>and sometimes it's because the vendor shows no intention of conforming to
>>standards (like Borland and Turbo Pascal).
>
>Sorry, but while Borland isn't 100% compliant, they are increasing their
>compliance. I've ported code from v3 to v4 and now to v5. I've had to "fix"
>non-compliant areas. 
>
Good. My statement was a generalization based on past history and their lack
of participation in standards activities. If Borland is starting to pay
attention to standards, more power (er, sales) to them. Also realize that
a vendor will only pay attention to standards if customers repeatedly
tell the vendor it is important.

usenet:	uunet!littlei!intelhf!ihf1!bobd		Bob Dietrich
  or	tektronix!ogccse!omepd!ihf1!bobd	Intel Corp., Hillsboro, Oregon
  or	tektronix!psu-cs!omepd!ihf1!bobd	(503) 696-2092

ipis@cdp.UUCP (02/16/89)

You're right, Bob, I had just never heard of the regulation that FOR
control variables be local.  Thanks.
--andy Perrin