Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

save memo to inifile

179 views
Skip to first unread message

tw

unread,
Apr 1, 2002, 8:46:14 AM4/1/02
to
I can't get this to loop around and write all the lines in the memo , all I
get is the last line of text in the memo?
Var
Ini: TiniFile;
I:integer;
Begin
Ini := Tinifile.create(ExtractFilePath(application.exename) + 'SQL.ini');
Try
for I:=0 to Memo1.Lines.Count-1 do begin
ini.writestring(DateTimeToStr(Now),'Line[I]' , Memo1.lines.Strings[I]);
end;
Finally
ini.free;
end;

Jesús Avilés Martínez

unread,
Apr 1, 2002, 9:06:32 AM4/1/02
to
tw wrote:

Try this:

begin
Memo1.Lines.SaveToFile(ExtractFilePath(Application.ExeName) + 'SQL.ini');
end;

--
JAM - Relįjate y disfruta...

Andy M.

unread,
Apr 1, 2002, 9:07:03 AM4/1/02
to
you probably should use
'Line[' + IntToStr(I) + ']'
instead of
'Line[I]'
in your call of Writestring,
because your example will always write the to the key with the name
'Lines[I]' and therefore overwrite the previously written values, whereas my
suggestion will create a new key for every line named 'Line[1]', 'Line[2]'
and so on. I guess this is what you wanted to achieve?

Andy

--
Kyoto Now !


Jesús Avilés Martínez

unread,
Apr 1, 2002, 9:14:04 AM4/1/02
to
Jesús Avilés Martínez wrote:

> tw wrote:
>
>> I can't get this to loop around and write all the lines in the memo ,
>> all I
>> get is the last line of text in the memo?
>> Var
>> Ini: TiniFile;
>> I:integer;
>> Begin
>> Ini := Tinifile.create(ExtractFilePath(application.exename) + 'SQL.ini');
>> Try
>> for I:=0 to Memo1.Lines.Count-1 do begin
>> ini.writestring(DateTimeToStr(Now),'Line[I]' , Memo1.lines.Strings[I]);
>> end;
>> Finally
>> ini.free;
>> end;
>>
>>
>>

Sorry for the above:

Var
Ini: TiniFile;
I:integer;

begin
Ini := TIniFile.Create(ExtractFilePath(Application.ExeName) +
'SQL.ini');
try


for I:=0 to Memo1.Lines.Count-1 do

Ini.WriteString(DateTimeToStr(Now),'Line[' + IntToStr(I) + ']' ,
Memo1.Lines[I]);
finally
Ini.Free;
end;
end;
--
JAM - Relájate y disfruta...

Michael Kelly

unread,
Apr 1, 2002, 1:36:59 PM4/1/02
to
On Mon, 1 Apr 2002 23:46:14 +1000, "tw" <tony...@primus.com> wrote:

>I can't get this to loop around and write all the lines in the memo , all I
>get is the last line of text in the memo?

If you end up with a lot of text in your memo for some
reason you might consider just putting the name of the
file in a key in the .ini file and using the SaveToFile perhaps
to save the memo in your app's folder. I think in Win9x the
.ini files stop working after a certain size(may be 32K but
I could be wrong.)


Mike

--

"Only choice is an oxymoron."

--

0 new messages