SRL Archive - General

Access Violation in 30 Line Script


asdfasdfasdf

2009-05-25 22:39:33

Where did I go wrong?

program New;
var
a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z: integer;
px,py: integer;
acc: extended;

procedure LoadPics;
begin
d:= LoadBitmap('.\letters\d.bmp');
e:= LoadBitmap('.\letters\e.bmp');
i:= LoadBitmap('.\letters\i.bmp');
r:= LoadBitmap('.\letters\r.bmp');
v:= LoadBitmap('.\letters\v.bmp');
end;

begin
writeln('Waiting 3 seconds..');
sleep(3000);
writeln('Searching..');
if(FindDeformedBitmapToleranceIn(d, px, py, 0, 0, 800, 600, 70, 0, True, acc)) then //PROBLEM LINE
begin
writeln('Found it');
end else
begin
writeln('No dice.');
end;
end.


senrath

2009-05-25 22:43:34

You never call LoadPics.

Shuttleu

2009-05-25 22:46:00

you havent loaded the bitmaps yet

~shut

EDIT:
program New;
var
a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z: integer;
px,py: integer;
acc: extended;

procedure LoadPics;
begin
d:= LoadBitmap('.\letters\d.bmp');
e:= LoadBitmap('.\letters\e.bmp');
i:= LoadBitmap('.\letters\i.bmp');
r:= LoadBitmap('.\letters\r.bmp');
v:= LoadBitmap('.\letters\v.bmp');
end;

begin
LoadPics;
writeln('Waiting 3 seconds..');
sleep(3000);
writeln('Searching..');
if(FindDeformedBitmapToleranceIn(d, px, py, 0, 0, 800, 600, 70, 0, True, acc)) then //PROBLEM LINE
begin
writeln('Found it');
end else
begin
writeln('No dice.');
end;
end.

marpis

2009-05-28 14:04:52

And btw, load the characters like this:

var
Char: array [0..25] of integer;
s: string;
i: integer;

begin
s := 'abcdefghijklmnopqrstuvwxyz';
for i := 0 to 25 do
Char[i] := LoadBitmap('.\letters\'+s[i]+'.bmp');
end;

and when you wanna find letter D, do this:
FindDeformedBitmapToleranceIn(Char[3], px, py, 0, 0, 800, 600, 70, 0, True, acc)