Board index » delphi » EDIT1.TEXT := MEMO1.Lines.Values['BFT1'];

EDIT1.TEXT := MEMO1.Lines.Values['BFT1'];

PROCEDURE TFORM1.ABC(SENDER: TOBJECT);
VAR
RINI:TINIFILE;
BEGIN
RINI := TINIFILE.CREATE('D:\BFT.INI');
MEMO1.CLEAR;
RINI.READSECTIONVALUES('BFT1',MEMO1.LINES);
EDIT1.TEXT := MEMO1.Lines.Values['BFT1'];
/////EDIT1.TEXT := 'THIS IS A TEST';
caption := edit1.text;
RINI.FREE;
END;
///////////////
Why does EDIT1.TEXT not assume the value of MEMO1.LINES.VALUES['BFT1']?
I have a MEMO1 and EDIT1 field on form1. The MEMO1 field shows the BFT1
value but the
EDIT1 field does not. If I assign the 'This is a test' string to EDIT1,
caption will display it.

When I use the above code in another unit it works fine.

Any help is greatly appreciated.

Werner

 

Re:EDIT1.TEXT := MEMO1.Lines.Values['BFT1'];


In article <357bf53...@hawk.pix.za>, Werner Hanses <data...@pixie.co.za>
writes

Quote
>PROCEDURE TFORM1.ABC(SENDER: TOBJECT);
>VAR
>RINI:TINIFILE;
>BEGIN
>RINI := TINIFILE.CREATE('D:\BFT.INI');
>MEMO1.CLEAR;
>RINI.READSECTIONVALUES('BFT1',MEMO1.LINES);
>EDIT1.TEXT := MEMO1.Lines.Values['BFT1'];
>/////EDIT1.TEXT := 'THIS IS A TEST';
>caption := edit1.text;
>RINI.FREE;
>END;
>///////////////
>Why does EDIT1.TEXT not assume the value of MEMO1.LINES.VALUES['BFT1']?
>I have a MEMO1 and EDIT1 field on form1. The MEMO1 field shows the BFT1
>value but the
>EDIT1 field does not. If I assign the 'This is a test' string to EDIT1,
>caption will display it.

>When I use the above code in another unit it works fine.

Probably because 'BFT1' is the name of a Section in your INI file, and
the Values property of a TStrings object returns a string of whatever is
to the right of the = sign in a Line Item of a Section. Unless you have
a section in your INI file that reads

[BFT1]
BFT1=42

...the assignment using the Values property will return an empty string.
--
Barney Tyrwhitt-Drake

Drake Software web site:  http://www.tdrake.demon.co.uk

Re:EDIT1.TEXT := MEMO1.Lines.Values['BFT1'];


Thank you for your reply Barney.
I do have a section that reads [BFT1] BFT1=42 in my INI file. The correct
value appears in MEMO1.
The problems seems to be with this line:EDIT1.TEXT :=
MEMO1.Lines.Values['BFT1'];

Werner

Quote
Barney Tyrwhitt-Drake wrote in message ...
>In article <357bf53...@hawk.pix.za>, Werner Hanses <data...@pixie.co.za>
>writes
>>PROCEDURE TFORM1.ABC(SENDER: TOBJECT);
>>VAR
>>RINI:TINIFILE;
>>BEGIN
>>RINI := TINIFILE.CREATE('D:\BFT.INI');
>>MEMO1.CLEAR;
>>RINI.READSECTIONVALUES('BFT1',MEMO1.LINES);
>>EDIT1.TEXT := MEMO1.Lines.Values['BFT1'];
>>/////EDIT1.TEXT := 'THIS IS A TEST';
>>caption := edit1.text;
>>RINI.FREE;
>>END;
>>///////////////
>>Why does EDIT1.TEXT not assume the value of MEMO1.LINES.VALUES['BFT1']?
>>I have a MEMO1 and EDIT1 field on form1. The MEMO1 field shows the BFT1
>>value but the
>>EDIT1 field does not. If I assign the 'This is a test' string to EDIT1,
>>caption will display it.

>>When I use the above code in another unit it works fine.

>Probably because 'BFT1' is the name of a Section in your INI file, and
>the Values property of a TStrings object returns a string of whatever is
>to the right of the = sign in a Line Item of a Section. Unless you have
>a section in your INI file that reads

>[BFT1]
>BFT1=42

>...the assignment using the Values property will return an empty string.
>--
>Barney Tyrwhitt-Drake

>Drake Software web site:  http://www.tdrake.demon.co.uk

Re:EDIT1.TEXT := MEMO1.Lines.Values['BFT1'];


Quote
Werner Hanses wrote in message <357bf53...@hawk.pix.za>...
>PROCEDURE TFORM1.ABC(SENDER: TOBJECT);
>VAR
>RINI:TINIFILE;
>BEGIN
>RINI := TINIFILE.CREATE('D:\BFT.INI');
>MEMO1.CLEAR;
>RINI.READSECTIONVALUES('BFT1',MEMO1.LINES);
>EDIT1.TEXT := MEMO1.Lines.Values['BFT1'];
>/////EDIT1.TEXT := 'THIS IS A TEST';
>caption := edit1.text;
>RINI.FREE;
>END;
>///////////////
>Why does EDIT1.TEXT not assume the value of MEMO1.LINES.VALUES['BFT1']?

                    Because I made the MEMO1 window to small!!
Quote
>I have a MEMO1 and EDIT1 field on form1. The MEMO1 field shows the BFT1
>value but the
>EDIT1 field does not. If I assign the 'This is a test' string to EDIT1,
>caption will display it.

>When I use the above code in another unit it works fine.

>Any help is greatly appreciated.

>Werner

Other Threads