Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.pascal.borland    |    Borland Pascal was actually pretty neat    |    2,978 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 1,484 of 2,978    |
|    Jim Higgins to xantarc    |
|    Re: Why "ILLEGAL COUNTER VARIABLE"?    |
|    25 Mar 05 14:21:36    |
   
   From: me7@privacy.net   
      
   On 24 Mar 2005 23:53:20 -0600, in <4243a750$1_1@127.0.0.1>,   
   legiamo_6660@yahoo-dot-com.no-spam.invalid (xantarc) wrote:   
      
   >Hi, I have the following error when I trying to compile a pascal   
   >program for sorting:   
   >ILLEGAL COUNTER VARIABLE , in the line   
   >BOLD;   
   >Anyone know how to deal with this problem?   
   >   
   >This is the program code :   
   >   
   >type   
   >arrin = array [1..5] of integer;   
   >var   
   >arra:arrin;   
   >m,i1,i2,y,ps,sted:integer;   
   >procedure intoarray (var arr:arrin; i:integer);   
   > begin   
   > i:=1;   
   > repeat   
   > readln(arr);   
   > i:= i+1;   
   > until (i=6);   
   > end;   
   >procedure bbssort(arr:arrin; var i,y,pass:integer;sorted:boolean);   
   > begin   
   > pass:=1;   
   > repeat   
   > sorted:=true;   
   > [b:d489e7fba9]FOR i:= 1 TO 5 DO[/b:d489e7fba9]   
   > begin   
   > if arr[i] > arr[i+1] then   
      
   Whoa! When i = 5, arr[i+1] refers to arr[6], but arr is defined   
   farther above as array[1..5] of integer.   
      
   > begin   
   > sorted:=false;   
   > y:=arr[i];   
   > arr[i]:=arr[i+1];   
   > arr[i+1]:=y;   
      
   Same problem in the two lines above, but you'll never get this   
   far.   
      
   > end;   
   > end;   
   > pass:=pass+1;   
   > until sorted;   
   > end;   
   >begin   
   >intoarray (arra,i1);   
   >bbssort (arra,i2,y,ps,sted);   
   >end.   
   >   
   >And I have Another program, I found run-time error 201,which means   
   >range check error;   
   >   
   >Anyone can tell me what happen in the   
   >[b:d489e7fba9]BOLD[/b:d489e7fba9] lines?   
   >   
   >PROGRAM sortt(output);   
   >   
   >type   
   >arrin=array[1..5] of integer;   
   >   
   >VAR i,y : integer;   
   >sorted:boolean;   
   > arr:arrin;   
   >BEGIN   
   > i:=1;   
   > repeat   
   > readln (arr[i]);   
   > writeln(arr[i]);   
   > i:=i+1;   
   > until (i=6);   
   > i := 1;   
   > FOR i := 1 TO 5 DO   
   > begin   
   > if arr[i] > arr[i+1] then   
      
   Same problem here.   
      
   > begin   
   > writeln('hello');   
   > sorted:=false;   
   > writeln(sorted);   
   > y:=arr[i];   
   > ARR [i]:=arr[i+1];   
   > [b:d489e7fba9]arr[i+1]:=y;   
      
   Same problem here, but you'll never get this far.   
      
   > writeln ( arr [2] );   
   > end;   
   > end;[/b:d489e7fba9]end.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca