PDA

View Full Version : Left side cannot be assigned to!



Diaboli
14-01-2007, 07:30 PM
type
TGameField = record
X,Y, MaxLen: Integer;
Text: String;
Font: TFont;
GotFocus, Password: Boolean;
end;

Function CurrField: TGameField;
var
i: Integer;
Fields: TFieldList;
begin

case GameState of
gsLogin: Fields:= TheLoginFields;
end;

for i := 0 to Length(Fields) - 1 do
begin
if Fields[i].GotFocus then Result:= Fields[i];
end;

end;

procedure FieldInput(input: Char);
begin
if Length(CurrField.Text) < Currfield.MaxLen then
CurrField.Text:= CurrField.Text+input;
end;


Any ideas?

its supposed to write to the field found by CurrField.

for example:
TheLoginFields[0].GotFocus is True;
then i want to write to it.
how should i do this (with as little stress on cpu as possible)

Clootie
14-01-2007, 08:19 PM
Changing to
Function CurrField: PGameField;
and taking address of rect inside function should work.

Diaboli
14-01-2007, 10:10 PM
hmm.. i dont understand what u just wrote, but i found a solution to my problem:


procedure FieldInput(input: Char);
var
i: Integer;
Fields: TFieldList;
begin

case GameState of
gsLogin: Fields:= TheLoginFields;
end;

for i := 0 to Length(Fields) - 1 do
begin
if Fields[i].GotFocus then
begin
if Length(Fields[i].Text) < Fields[i].MaxLen then
Fields[i].Text:= Fields[i].Text+input;
end;
Exit;
end;
end;

no need to make it more complicated than needed... :P