mtbb114@ms.uky.edu (Jerry Duffy) (02/17/91)
This maybe a stupid question, but does anyone know what it means when it gives the error number 172 'Control variable of a for statement must be local?' This is the DYNIX Pascal compiler on the UNIX system. This error has me baffled.. Thanks. Jerry Duffy mtbb114@s.ms.uky.edu -- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- !Maleck - High Lord of the Cosmos | "It was Randell Flagg. It was ! ! and Led Zep Fanatic. | the Walkin' Dude." ! ! mtbb114@s.ms.uky.edu | -Stephen King !
nmouawad@watmath.waterloo.edu (Naji Mouawad) (02/18/91)
In article <mtbb114.666785733@s.ms.uky.edu> mtbb114@ms.uky.edu (Jerry Duffy) writes: >This maybe a stupid question, but does anyone >know what it means when it gives the error >number 172 'Control variable of a for statement >must be local?' > >This is the DYNIX Pascal compiler on the UNIX >system. This error has me baffled.. Thanks. > >Jerry Duffy >mtbb114@s.ms.uky.edu This is a Standard Pascal Error: you cannot use a parameter to a procedure or a function as a control variable within a for loop. That is: procedure Notsogood(var i : integer); begin For i := 1 to 5 do writeln('this will give error 172, tidlidoo'); end; I am not sure wether using a global variable is allowed, although I suspect that this may be allowed. --Naji -- ------------------------------------------------------------------- | Naji Mouawad | nmouawad@watmath.waterloo.edu | | University |---------------------------------------------------| | Of Waterloo | "The Stranger in us is our most familiar Self" |
A.G.Poole@newcastle.ac.uk (Ford (Alex Poole)) (02/19/91)
mtbb114@ms.uky.edu (Jerry Duffy) writes: >This maybe a stupid question, but does anyone >know what it means when it gives the error >number 172 'Control variable of a for statement >must be local?' The problem is probably in a function or procedure; you have to define the variable being used in the FOR loop within the procedure, even if it normally exists as a global. eg PROGRAM blah (etc.); VAR i:INTEGER; PROCEDURE loop; VAR i:INTEGER; BEGIN FOR i:=1 TO 1 DO writeln END; BEGIN loop END. As it stands, you'll get a 'variable i declared but not used' message instead, as its defined globally but only used locally. Hope that helps!! Ford ----- I come from a good home - thats why they don't want me back.
ebergman@isis.cs.du.edu (Eric Bergman-Terrell) (02/21/91)
The error message is accurate. Your program has a statement like: for i := 1 to 100 do ... But the loop variable (i) must be a local variable. This is a rule of Pascal that is unenforced on some compilers... Terrell