Substring is annoying...

Started by NsMn, Tue 27/10/2009 15:56:09

Previous topic - Next topic

NsMn

...wanna know why?

Because it uses an index and a string length, which is useless for me know.
Is there any way to do this, a Sunstring function that returns a string from index to index?
Like, a module or a good workaround?

AJA

Substring( startIndex, endIndex - startIndex ) perhaps?

Crimson Wizard

Quote from: AJA on Tue 27/10/2009 16:02:16
Substring( startIndex, endIndex - startIndex ) perhaps?
Actually Substring( startIndex, endIndex - startIndex +1)

NsMn

Uhm. Oops. Yes.... thank you two.

monkey0506

To simplify things for yourself you could write an extender:

Code: ags
String Substring2(this String*, int start, int end) {
  return this.Substring(start, end - start + 1);
}

String s = "Hello world!";
String t = s.Substring2(6, 10);
Display(t); // Displays "world"

Khris

I'm going to write the module for that.
Expect a beta version around December.

SMF spam blocked by CleanTalk