Alpha IIMedlem sedan maj 20002 993 inlägg Varför fungerar inte det här?
var
F : TextFile;
X : Integer;
Y : Integer;
S : String;
begin
AssignFile(F, FileName);
Reset(F);
for X := 0 to 9 do begin
ReadLn(F, S);
for Y := 0 to 9 do begin
Table[X,Y].Image := StrToInt(S[Y]); <-- Blir ett exception här när programmet körs...
Table[X,Y].Visible := Bool(Table[X,Y].Image);
Table[X,Y].Rect.Left := X*BlockWidth;
Table[X,Y].Rect.Right := (X+1)*BlockWidth;
Table[X,Y].Rect.Top := Y*BlockHeight;
Table[X,Y].Rect.Bottom := (Y+1)*BlockHeight;
end;
end;
CloseFile(F);
BeatboxMedlem sedan okt. 20013 217 inlägg Table[X,Y].Image := StrToInt(S[Y]);
Borde inte Table[X,Y].Image vara av typen TImage ?
jtMedlem sedan juni 2000350 inlägg Första tecknet i en sträng är position 1.
S := ABC
S[1] = A
Du startar din Loop på noll.
Alpha IIMedlem sedan maj 20002 993 inlägg Image är en Integer.
Det är bara vilken pattern som ska ritas (DelphiX)
BeatboxMedlem sedan okt. 20013 217 inlägg Så här stod det i hjälpen i alla fall.
StrToInt converts the string S, which represents an integer-type number in either decimal or hexadecimal notation, into a number. If S does not represent a valid number, StrToInt raises an EConvertError exception.