ActualNoob
2013-05-31 10:43:22
Hey all iam a newbie to scripting and simba, hopefully someone can help me.
Iam getting this error when trying to compile. "[Error] Type mismatch at line 89" this is highlighted at setTiles(map);
my question is why is this happening? arent both the procedure(setTiles) parameter list and the variable "map" of the same type(Array of Array of Node)?
What this script is supposed to do:
the text.txt is in the format of:
map is defined as a variable
my main method contains
and the procedure contains
Iam getting this error when trying to compile. "[Error] Type mismatch at line 89" this is highlighted at setTiles(map);
my question is why is this happening? arent both the procedure(setTiles) parameter list and the variable "map" of the same type(Array of Array of Node)?
What this script is supposed to do:
- Reads x,y coordinates from a file.
- Extracts the coordinates into pieces(TStringList).
- sets map[x][y].status to 1 if that coordinate exist in the file. (status is a integer variable of the Node record.)
the text.txt is in the format of:
129, 51
512, 61
0, 51
52, 52
map is defined as a variable
var
map : Array[0..512] of Array[0..512] of Node;
my main method contains
setTiles(map); and the procedure contains
procedure setTiles(var grid : array of array of Node);
var
a : String;
i,j,k,index: Integer;
file : Integer;
pieces : TStringList;
begin
pieces := TStringList.Create;
file := OpenFile('C:\Users\pokemon\Desktop\bot\text.txt',true);
ReadFileString(file,a,FileSize(file));
SplitRegExpr('[^[0-9]*\s', a,pieces);
j := 1;
k := 0;
index :=0;
//sets nodes for coordinates (x,y) to walkable
for i:=0 to (pieces.Count/2)-1 do
begin
grid[StrToInt(pieces.Strings[k])][StrToInt(pieces.Strings[j])].status := 1 ;
index := index +1;
k := k +2;
j := j +2;
end;
pieces.Free;
end;