Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: NsMn on Tue 27/10/2009 15:56:09

Title: Substring is annoying...
Post by: NsMn on Tue 27/10/2009 15:56:09
...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?
Title: Re: Substring is annoying...
Post by: AJA on Tue 27/10/2009 16:02:16
Substring( startIndex, endIndex - startIndex ) perhaps?
Title: Re: Substring is annoying...
Post by: Crimson Wizard on Tue 27/10/2009 16:05:33
Quote from: AJA on Tue 27/10/2009 16:02:16
Substring( startIndex, endIndex - startIndex ) perhaps?
Actually Substring( startIndex, endIndex - startIndex +1)
Title: Re: Substring is annoying...
Post by: NsMn on Tue 27/10/2009 16:10:32
Uhm. Oops. Yes.... thank you two.
Title: Re: Substring is annoying...
Post by: monkey0506 on Tue 27/10/2009 16:41:32
To simplify things for yourself you could write an extender:

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"
Title: Re: Substring is annoying...
Post by: Khris on Wed 28/10/2009 02:37:17
I'm going to write the module for that.
Expect a beta version around December.