SRL Archive - OSR Help

String manipulation (getting first 3 characters)


Cstrike

2010-10-09 22:34:33

I don't know what's been carried over from scar. I checked Simba documentation and the String functions aren't commented so I feel as if I'm in the dark. (Wizzup, if you check this, please correct me if I'm wrong, I checked http://wizzup.org/simbadoc/ and the String functions werent documented besides what they do – if there is full documentation somewhere, i'll take a link and read up on it)
This is a purely simba script… no SCAR functions.

For example, I want to get:
Thank goodness you're here! My squire's dead, and

The first 3 letters into a string, or a function that returns true if it finds 'Tha'. I can't just use "check if string = this' because it has apostrophe's in there which screws up my string. Unless there's a way to get rid of those ;)
Didn't realize how weak I am at modding strings…

EDIT: I found this thread
http://villavu.com/forum/showthread.php?t=55893&highlight=string
Which solves my problem, but I'd still like to know if there are other string manipulation tools I could use.

EvilChicken!

2010-10-09 22:42:37

You could use StrGet, if that's what the function name was?
Or, there's also a possibility to do "String[1] + String[2] + String[3]", if you want a more clumsy way. :p

Daniel

2010-10-09 22:50:50

if(Pos('tha', 'thank goodness you're here! My squire''s dead, and') = 1) then
// 'tha' is located at position 1 of the string!

S := Copy('thank goodness you're here! My squire''s dead, and', 1, 3);
// Copies from position 1 to 3 of a string

EvilChicken!

2010-10-09 22:54:26

Copy! It was Copy!
Ah, thanks, Dan. StrGet must be from SCAR, then.
.. it's obviously been a while since I've been doing this..

Awkwardsaw

2010-10-09 23:29:20

From: EvilChicken!
Copy! It was Copy!
Ah, thanks, Dan. StrGet must be from SCAR, then.
.. it's obviously been a while since I've been doing this..


copy was in SCAR aswell. ;)

Daniel

2010-10-10 00:03:51

From: EvilChicken!
Copy! It was Copy!
Ah, thanks, Dan. StrGet must be from SCAR, then.
.. it's obviously been a while since I've been doing this..

There is no strget in anything (from what I know of).

Nava2

2010-10-11 16:11:00

strget is in PHP i think..

nielsie95

2010-10-11 16:45:52

StrGet gets a character at a certain position, like String[Index].

i luffs yeww

2010-10-11 19:59:50

^ Is it SCAR/SRL/Simba related though? I don't recall there being a StrGet function but then I kinda do then I kinda don't. :p

Sandstorm

2010-10-16 11:23:30

program New;
var
s : string;

begin
s := '5000';
Writeln(StrGet(s, 4));
end.

In SCAR.

Also, to add an apostrophe in a string it's just two of them (ie. '').