Log in

View Full Version : Pos?



Jason2gs
03-17-2007, 03:42 PM
In several scripts, I've seen the word "Pos" when dealing with the chat box and usernames. How do I use this? I assume "Pos" stands for "Position", right? So does that mean I can take seperate the username from the rest of the GetText I'm using?

Pentti
03-17-2007, 03:52 PM
Yup, it stands for position.
Maybe this tells something:
program New;
const
TextToFind='middle';
FromText='da middle is here';
begin
writeln(inttostr(pos(TextTofind,FromText)))
end.
if you search for word 'middle' from text 'da middle is here', you can see that middle starts at 4th letter.

Boreas
03-17-2007, 03:55 PM
function pos(substr, s: string): Longint; - returns position of substring in string. Returns 0 if not found.

From SCAR F1 Help


program New;
{.include SRL/SRL.scar}

var MyString, LittleString:string;

PositionOfLittleStringInMyString:integer;
begin
SetupSRL;
MyString:='The quick red fox jumped over the lazy brown dog';
LittleString:='quick';
PositionOfLittleStringInMyString:=Pos(LittleString ,MyString);
writeln(inttostr(PositionOfLittleStringInMyString) );
end.

Edit: Pentti beat me

Pentti
03-17-2007, 04:00 PM
Edit: Pentti beat me
Yay! :D But you beat me in explaining of this, you had more info about it.
btw, why you had SRL in your example? :D

Jason2gs
03-17-2007, 04:01 PM
Thank you guys :)

Now I can start work on my AutoReporter...

Thanks again :p