SRL Archive - OSR Help

I think I'm blind


omgnomorenames

2012-09-07 15:03:11

Getting [Error] (1:1): Variable Expected at line 0
I know it's probable something simple, but i can't seem to find it…
program new;
var
Board :Array [0..8] of Array [0..8] of Integer;
Lines :Array[0..8] of String;
Count1,Count2 :Integer;

Function RowColumnBox (var RowColumn:Integer):Integer;
Begin
if (RowColumn > 5) then
Begin
Result:= 2;
end else if (RowColumn > 2) then begin
Result:= 1;
end else
Result := 0;
End;

Function CheckDigit (var Row, Column:Integer):Boolean;
var Count,Count2:Integer;
Begin
Result := True;
For Count:= 0 to 8 do
Begin
if (Board[Row][Column] = Board [Count][Column]) and not(count = Row) then
Begin
Result:= False;
Exit;
End;
if (Board[Row][Column] = Board [Row][Count]) and not(Count = Column) then
Begin
Result:= False;
Exit;
End;
End;
For Count:= (RowColumnBox(Row)*3) to (RowColumnBox(Row)*3 + 2) do
For Count2 := (RowColumnBox(Column)*3) to (RowColumnBox(Column)*3 + 2) do
Begin
if (Board[Count][Count2] = Board[Row][Column]) and not((Count = Row) and (Count2 = Column)) then
Result := False;
Exit;
End;
End;

Function FindDigit (var Row,Column: Integer):Boolean;
var Count:Integer;
Begin
Result:=False;
if (Column > 8) then
Begin
Inc(Row);
Column := 0;
if (Row > 8) then
Begin
Result:= True;
Exit;
End;
End;
if not(Board[Row][Column] = 0)then
Begin
Result := FindDigit(Row,Column+1);
End Else Begin
For Count := 1 to 9 do
Begin
Board[Row][Column]:=Count;
if (CheckDigit) then
if (FindDigit(Row,Column+1))then
Begin
Result:=True;
Exit;
End;
End;
Board[Row][Column]:=0;
End;
End;

begin
Board[0]:=[0,0,0,0,0,0,0,0,0];
Board[1]:=[0,0,0,0,0,0,0,0,0];
Board[2]:=[0,0,0,0,0,0,0,0,0];
Board[3]:=[0,0,0,0,0,0,0,0,0];
Board[4]:=[0,0,0,0,0,0,0,0,0];
Board[5]:=[0,0,0,0,0,0,0,0,0];
Board[6]:=[0,0,0,0,0,0,0,0,0];
Board[7]:=[0,0,0,0,0,0,0,0,0];
Board[8]:=[0,0,0,0,0,0,0,0,0];
FindDigit[0,0];
for Count1 := 0 to 8 do
for Count2 := 0 to 8 do
Begin
Lines [Count1] := '|'+ToStr (Board[count1][count2])+'|';
End;
for Count1 := 0 to 8 do
writeln (Lines[Count1]);
end.

Rezozo

2012-09-07 15:06:33

Are you useing this for RS (in simba?)? If so define everything, SMART, SPS everything.

If not, then add a using software, like Uses Wincrt

omgnomorenames

2012-09-07 15:14:09

JoeyGupta your comment made me mad.

Footy

2012-09-07 15:20:16

Your standards make it difficult to find the problem. When its something to do with line 0, its usually a main loop issue. Thats what its been in my experiences anyways. Count your begin's and ends, and make sure they match.

J J

2012-09-07 15:24:26

The problem with the [Error] (1:1): Variable Expected at line 0 was that you put var in the functions like this: Function Test(var Test: Integer) and it should be Function Test(Test: Integer). But you also messed up with some () and [] but this compiles, slightly edited. It's a lot easier to find your mistakes if you use the proper standards, I have updated them a bit while searching for the mistake..

program new;
{$i SRL/srl.simba}

var
Board: Array[0..8] of Array[0..8] of Integer;
Lines: Array[0..8] of String;
Count1, Count2: Integer;

Function RowColumnBox(RowColumn: Integer):Integer;
Begin
if (RowColumn > 5) then
Begin
Result:= 2;
end else if (RowColumn > 2) then
begin
Result:= 1;
end else
Result := 0;
End;

Function CheckDigit(Row, Column:Integer):Boolean;
var Count,Count2:Integer;

Begin
Result := True;
For Count:= 0 to 8 do
Begin
if (Board[Row][Column] = Board[Count][Column]) and not(count = Row) then
Begin
Result:= False;
Exit;
End;
if (Board[Row][Column] = Board[Row][Count]) and not(Count = Column) then
Begin
Result:= False;
Exit;
End;
End;

For Count:= (RowColumnBox(Row)*3) to (RowColumnBox(Row)*3 + 2) do
For Count2 := (RowColumnBox(Column)*3) to (RowColumnBox(Column)*3 + 2) do
Begin
if (Board[Count][Count2] = Board[Row][Column]) and not((Count = Row) and (Count2 = Column)) then
begin
Result := False;
Exit;
End;
End;
end;

Function FindDigit(Row,Column: Integer):Boolean;
var Count:Integer;

Begin
Result:=False;
if (Column > 8) then
Begin
Inc(Row);
Column := 0;
if (Row > 8) then
Begin
Result:= True;
Exit;
End;
End;

if not(Board[Row][Column] = 0)then
Begin
Result := FindDigit(Row,Column+1);
End Else
Begin
For Count := 1 to 9 do
Begin
Board[Row][Column]:=Count;
if (CheckDigit(Row, Column)) then
if (FindDigit(Row,Column+1))then
Begin
Result:=True;
Exit;
End;
End;
Board[Row][Column]:=0;
End;
End;

begin
Board[0]:=[0,0,0,0,0,0,0,0,0];
Board[1]:=[0,0,0,0,0,0,0,0,0];
Board[2]:=[0,0,0,0,0,0,0,0,0];
Board[3]:=[0,0,0,0,0,0,0,0,0];
Board[4]:=[0,0,0,0,0,0,0,0,0];
Board[5]:=[0,0,0,0,0,0,0,0,0];
Board[6]:=[0,0,0,0,0,0,0,0,0];
Board[7]:=[0,0,0,0,0,0,0,0,0];
Board[8]:=[0,0,0,0,0,0,0,0,0];
FindDigit(0,0);
for Count1 := 0 to 8 do
for Count2 := 0 to 8 do
Begin
Lines [Count1] := '|'+ToStr (Board[count1][count2])+'|';
End;
for Count1 := 0 to 8 do
writeln (Lines[Count1]);
end.

i luffs yeww

2012-09-07 15:26:21


var
Board: Array [0..8] of Array [0..8] of Integer;
Lines: Array [0..8] of String;
Count1, Count2: Integer;

function RowColumnBox(RowColumn: Integer): Integer;
begin
if (RowColumn > 5) then
Result := 2
else
if (RowColumn > 2) then
Result := 1
else
Result := 0;
end;

function CheckDigit(Row, Column: Integer): Boolean;
var
Count, Count2: Integer;
begin
Result := True;
for Count:= 0 to 8 do
begin
if (Board[Row][Column] = Board [Count][Column]) and not(count = Row) then
begin
Result := False;
Exit;
end;
if (Board[Row][Column] = Board [Row][Count]) and not(Count = Column) then
begin
Result := False;
Exit;
end;
end;
for Count := (RowColumnBox(Row) * 3) to (RowColumnBox(Row) * 3 + 2) do
for Count2 := (RowColumnBox(Column) * 3) to (RowColumnBox(Column) * 3 + 2) do
begin
if (Board[Count][Count2] = Board[Row][Column]) and
not((Count = Row) and (Count2 = Column)) then
begin
Result := False;
Exit;
end;
end;
end;

function FindDigit(Row, Column: Integer): Boolean;
var
Count: Integer;
begin
Result := False;
if (Column > 8) then
begin
Inc(Row);
Column := 0;
if (Row > 8) then
begin
Result := True;
Exit;
end;
end;
if not(Board[Row][Column] = 0)then
begin
Result := FindDigit(Row, Column + 1);
end else
begin
for Count := 1 to 9 do
begin
Board[Row][Column] := Count;
if (CheckDigit) then
if (FindDigit(Row, Column + 1)) then
begin
Result := True;
Exit;
end;
end;
Board[Row][Column]:=0;
end;
end;

begin
Board[0] := [0, 0, 0, 0, 0, 0, 0, 0, 0];
Board[1] := [0, 0, 0, 0, 0, 0, 0, 0, 0];
Board[2] := [0, 0, 0, 0, 0, 0, 0, 0, 0];
Board[3] := [0, 0, 0, 0, 0, 0, 0, 0, 0];
Board[4] := [0, 0, 0, 0, 0, 0, 0, 0, 0];
Board[5] := [0, 0, 0, 0, 0, 0, 0, 0, 0];
Board[6] := [0, 0, 0, 0, 0, 0, 0, 0, 0];
Board[7] := [0, 0, 0, 0, 0, 0, 0, 0, 0];
Board[8] := [0, 0, 0, 0, 0, 0, 0, 0, 0];
FindDigit[0, 0];
for Count1 := 0 to 8 do
for Count2 := 0 to 8 do
Lines[Count1] := '|' + ToStr(Board[count1][count2]) + '|';
for Count1 := 0 to 8 do
Writeln(Lines[Count1]);
end.

Standards, man.

Anyway, taking out the "vars" in the function declarations fixed the problem.

You still have several other problems in there, but you're a member - you can figure it out.

EDIT:

Not fast enough. :(

omgnomorenames

2012-09-07 15:40:59

Wow, I just woke up about 2 hrs ago and have massive hang over scripting was not a good idea lmao. Thank you guys.

One more thing what is the correct way to do this

Board[0] := [0, 0, 0, 0, 0, 0, 0, 0, 0];

Coh3n

2012-09-07 17:50:50

From: omgnomorenames
Wow, I just woke up about 2 hrs ago and have massive hang over scripting was not a good idea lmao. Thank you guys.

One more thing what is the correct way to do this

Board[0] := [0, 0, 0, 0, 0, 0, 0, 0, 0];
You can't assign the array like that (because of how you declared it). You declared it like:

Try declaring it like this:

Board: array[0..2] of TIntegerArray;