Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[Delphi] reading through tMemo lines

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Snootae
Grandmaster Cheater
Reputation: 0

Joined: 16 Dec 2006
Posts: 969
Location: --->

PostPosted: Mon May 05, 2008 6:10 am    Post subject: [Delphi] reading through tMemo lines Reply with quote

so i've got this code:

Code:
 for i := 0 to MemoActions.Lines.Count - 1 do


to count through my lines, but how do i determine if im on the last line?
i tried to do

Code:
if i + 1 = MemoActions.Lines.Count then
begin
//do stuff
end;


i think i might but just a little bit wrong, but how do i get it to work?

_________________
Back to top
View user's profile Send private message
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Mon May 05, 2008 6:46 am    Post subject: Reply with quote

Code:
procedure TForm1.Button1Click(Sender: TObject);
var
i: integer;
begin
for i := 0 to MemoActions.Lines.Count - 1 do
  begin
    if i = MemoActions.Lines.Count -1 then
      ShowMessage('Last line')
    else
      ShowMessage('Line:'+IntToStr(i+1));
  end;
end;


This will say "Last line" if it's the last line and "Line: <linenumber>" if it's not.
Back to top
View user's profile Send private message
Snootae
Grandmaster Cheater
Reputation: 0

Joined: 16 Dec 2006
Posts: 969
Location: --->

PostPosted: Mon May 05, 2008 6:58 am    Post subject: Reply with quote

thanks, lemme try
_________________
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 474

Joined: 09 May 2003
Posts: 25968
Location: The netherlands

PostPosted: Mon May 05, 2008 7:42 am    Post subject: Reply with quote

also, if you're obsessed about gaining an almost unnoticeable speed gain:
Code:

for i := 0 to MemoActions.Lines.Count - 2 do
begin
  ShowMessage('Line:'+IntToStr(i+1));
end;

i:=MemoActions.Lines.Count -1;
ShowMessage('Last line');

This way it'll have one less compare in the loop

_________________
Tools give you results. Knowledge gives you control.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
haha01haha01
Grandmaster Cheater Supreme
Reputation: 0

Joined: 15 Jun 2007
Posts: 1233
Location: http://www.SaviourFagFails.com/

PostPosted: Mon May 05, 2008 8:41 am    Post subject: Reply with quote

Dark Byte wrote:
also, if you're obsessed about gaining an almost unnoticeable speed gain:
Code:

for i := 0 to MemoActions.Lines.Count - 2 do
begin
  ShowMessage('Line:'+IntToStr(i+1));
end;

i:=MemoActions.Lines.Count -1;
ShowMessage('Last line');

This way it'll have one less compare in the loop

Lol, so predictable of u trying to make the shortest and fastest code Laughing
Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites