SRL Archive - Help and Support

Counting a word.


BobboHobbo

2008-02-14 02:26:28

How to make something that counts how many words of the word exit is in a script?

EDIT**

Like in my script if i had.

Procedure jfied;
begin
Exit;
exit;
exit;
end;

How would i make the script count all the exits?

Garrett

2008-02-14 03:30:45

umm… I think this might be it.
I've never done something like this in scar, so lets hope I'm correct :p

-Removed- Go to my next post

Ok, all it does… finds the the lowercase text, inside the lowercase string… and it deletes them as it finds them, while also counting… then subtract 1 from the final result due to it counting 1 extra because that is when it fails.

Here is a function for it:

-Removed- Go to my next post

To use it:
WriteLN(IntToStr(CountTextInString('gyjt, fisj, text, djftextft, fjs, text, text, 496,5653,35,345,3,5,f,f,s,df,,f,s,,text,535,5345,3,53,4text,,,sf3,53,,,text235235,text', 'text')));

That has 8 'text' strings in it.

EDIT

Cleaned Up:

-Removed- Go to my next post

Negaal

2008-02-14 03:36:58

There is function made by mixter…what counts begins, ends, etc, im sure you can use it on exits aswell

Garrett

2008-02-14 03:39:59

From: Negaal
There is function made by mixter…what counts begins, ends, etc, im sure you can use it on exits aswell

With mine, you can search any word :D
Well, lets hope so… lol, we'll see what happens.

_____________________________________________________________

Would it be better to use 'Pos' instead of 'PosEx'?

Anyways:
I think this one might prevent errors that might happen with PosEx? not sure..
{By: Garrett92
Description: Returns the amount of times it finds 'T' inside of 'S'}

Function CountTextInString(S, T: String): Integer;
Var
I, N: Integer;
Begin
Repeat
I := I + 1;
N := Pos(LowerCase(T), LowerCase(S));
Delete(S, N, Length(T));
Until(N = 0);
Result := I - 1;
End;


Edit

WriteLN(IntToStr(CountTextInString(GetPage('http://garrett92.freehostia.com/exit.txt'), 'exit;')));

It should find 4 'exit;'… I think it would work on a script if it can find it from a webpage.

BobboHobbo

2008-02-14 04:15:54

From: Garrett92
With mine, you can search any word :D
Well, lets hope so… lol, we'll see what happens.

_____________________________________________________________

Would it be better to use 'Pos' instead of 'PosEx'?

Anyways:
I think this one might prevent errors that might happen with PosEx? not sure..
{By: Garrett92
Description: Returns the amount of times it finds 'T' inside of 'S'}

Function CountTextInString(S, T: String): Integer;
Var
I, N: Integer;
Begin
Repeat
I := I + 1;
N := Pos(LowerCase(T), LowerCase(S));
Delete(S, N, Length(T));
Until(N = 0);
Result := I - 1;
End;


Edit

WriteLN(IntToStr(CountTextInString(GetPage('http://garrett92.freehostia.com/exit.txt'), 'exit;')));

It should find 4 'exit;'… I think it would work on a script if it can find it from a webpage.


Ooo, ill try that.

@Negal, if Garrets one doesnt work for me, link me :)

n3ss3s

2008-02-14 08:02:00

Go to the function thread of mine in SRL New Functions, and grab the BetweenEx.

Then you'll survive with a GetArrayLength :)

Though Garrett's may fit your needs better.

mastaraymond

2008-02-14 13:36:33

How funny, I posted in your other thread a function that counts text…

How-ever I would refer you to my obfuscater, since that does like the same as yours..

It counts words, (only if it are words.. Meaning that 232exit12 doesn't count).
Doesn't read Comments etc…