Solved DELPHI incompatable type?

September 4, 2011 at 06:10:39
Specs: Windows Vista
I'm new at this so please be gentle. The code below should place the contents of a text file in the memo box. The user enters a line number in one of the edit boxes and that line is displyed in the other edit box. Trouble is it conks out compiling the last line. Any ideas anyone?

fileData : TStringList; //Our TStringList variable
find : integer; //User Input


fileData := TStringList.Create; // Create the TSTringList object
memo1.lines := fileData; // Display text file
find := edit2.Text ; // Get line number from user
edit1.Text:=(filedata[find-1]); //Display selected text


Many thanks to anyone who can help.

See More: DELPHI incompatable type?

Report •

September 4, 2011 at 06:47:23
I don't know Delphi, just its ancestor Pascal, so take this as a temptative.

If Delphi is case sensitive you coded filedata instead of fileData on the last line.

Report •

September 4, 2011 at 07:19:46
Thanks, but Delphi is not case sensitive.

Report •

September 4, 2011 at 11:08:28
✔ Best Answer
My Delphi is a little rusty, but I think you are trying to assign a string to an integer in the line:

find := edit2.Text;

I think you need to use the StrToInt function to convert the string into an integer and then do the assignment.

Report •

Related Solutions

September 4, 2011 at 20:42:48
Thanks iJack, I'll give it a try and let you know.

Report •

September 4, 2011 at 21:13:00
Hi ijack. Put this in.

find := strtoint(edit2.Text) ;

Came up with an exception error. Edit2 is not a valid integer.
Had a thought - Edit2 needs a valid number in its text property and not its 'Text' value.

Report •

Ask Question