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 


A label counting words... (Delphi)

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

Joined: 07 Mar 2007
Posts: 1139
Location: Spiderman-World

PostPosted: Thu Aug 23, 2007 6:25 am    Post subject: A label counting words... (Delphi) Reply with quote

Im making a notepad program (for school use).

I want to be able to see how many words i used, how can i do this?
Also i want to be able to could count every single thing i post, ect:

1 2 3

Then the label would show 5, because the spaces is involved too...

If you don't get me i'll try to explain again.
Back to top
View user's profile Send private message MSN Messenger
assaf84
Expert Cheater
Reputation: 0

Joined: 03 Oct 2006
Posts: 238

PostPosted: Thu Aug 23, 2007 6:33 am    Post subject: Reply with quote

Let's say you put it all in a memo. What you need to do is loop all the lines, and in every line loop all the chars, and search for spaces. The number of words will be the number of spaces plus the number of lines plus 1. If you don't get it take some examples.
If you want to know the total number of chars just loop every line and every chars and count them.
Back to top
View user's profile Send private message
Kevin
Grandmaster Cheater Supreme
Reputation: 0

Joined: 07 Mar 2007
Posts: 1139
Location: Spiderman-World

PostPosted: Thu Aug 23, 2007 6:35 am    Post subject: Reply with quote

could you give me an example code? not the full code or anything, just so i got something i can build it on. thanks
Back to top
View user's profile Send private message MSN Messenger
assaf84
Expert Cheater
Reputation: 0

Joined: 03 Oct 2006
Posts: 238

PostPosted: Thu Aug 23, 2007 6:49 am    Post subject: Reply with quote

Let's say the user writes in Memo1, char's count in Label1 and word's count in Label2.
In Memo2Change or something:
Code:

var
i,j: Integer;
charCount: integer;
wordCount: Integer;
begin
wordCount = 0;
charCount = 0;
for i:=0 to Memo1.Lines.Count-1 do //I'm not sure, check it in delphi
begin
  for j:=0 to Memo1.Lines[i].GetLength-1 do //I'm pretty sure it's not true, again, check it
  begin
    charCount := charCount+1;
    if Memo1.Lines[i][j] = ' ' then
      wordCount = wordCount + 1;
  end;
  wordCount = wordCount + 1;
end;
Label1.Caption := IntToStr(charCuont);
Label2.Caption := IntToStr(wordCuont);
end;


Hope this helps Smile
Back to top
View user's profile Send private message
Kevin
Grandmaster Cheater Supreme
Reputation: 0

Joined: 07 Mar 2007
Posts: 1139
Location: Spiderman-World

PostPosted: Thu Aug 23, 2007 7:05 am    Post subject: Reply with quote

It gave me an idea, but as you said some of it are wrong. but thanks!
Back to top
View user's profile Send private message 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