: : :
This message was edited by sarkiemarkie at 2006-2-10 14:46:27
: : :
procedure TForm2.Edit1Exit(Sender: TObject);
: : : {the member number is checked to see if it contains only numbers}
: : : var
: : : i:integer;
: : : ok,inuse:boolean;
: : : begin
: : : ok := true;
: : : inuse:=false;
: : : for i:= 1 to length(edit1.text) do {checks the member Number for digits}
: : : begin
: : : if not (edit1.text[i] in Digits) then
: : : ok := false;
: : : end;
: : :
: : : assignfile(memberfile,'members.dat');
: : : reset(memberfile);
: : : read(memberfile,memberrecord);
: : : for i:= 1 to filesize(memberfile) do
: : : if memberrecord.Membernumber = strtoint(edit1.text) then
: : : inuse:=true;
: : :
: : :
: : :
: : : if ok=false then edit1.Color:=clLime;
: : : if inuse=true then edit1.Color:= clyellow; {checks for duplication}
: : : if length(edit1.Text)=0 then edit1.Color:=clred {checks for presence}
: : : else edit1.color:=clWhite;
: : :
: : :
: : : end;
: : :
: : : the for loops doint work. It says that the i variable is "inaccessable here due to optimization" when i put a watch on the i and thats why the for loops are not working
: : :
: : : whats wrong?
: : :
: : :
: : Which line does it say that? I cannot see where that error would occur.
: :
:
: it doesnt come up as an error but the for statements werent working properly so i put a watch on i and where it came to the for statements, thats the message that appear in i where an integer should have been.
:
:
The second loop is not necessary, because during that loop the memberrecord value and the edit1.text do not change, thus the if-then will not change after the first run. Delphi optimalizer probably removed the loop, and kept the if-then statement within it.