playMaker

Author Topic: SubStrings  (Read 3118 times)

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 318
SubStrings
« on: November 28, 2012, 10:36:48 PM »
I have a newb question, since I only use playmaker to script I'm not familiar with the term 'Substring' in the context of Playmaker String variables.

I feel like I could figure it out if it weren't for the terminology used in the action and documentation.  I'm told to specify an "Index", which is an integer field, but I don't know what that's actually looking for.

I tried looking up this information in various programming resources, but all the answers I found were specific to the language whatever article was written for.  I'd really appreciate it if someone could explain this in plain english.  Is a substring user-defined?  What is the "Index" value?  How does the Get Substring action differ from the Get String Left/Right, which I have been using up until now?

Thanks as always!

DARK_ETERNAL

  • Full Member
  • ***
  • Posts: 110
Re: SubStrings
« Reply #1 on: December 05, 2012, 04:38:06 PM »
Nah. A substring is the same for every language, and, for Playmaker.

For any programming language, as you might already know, a substring is a portion of a string, being itself a string, and a string is a char array.

The "Start Index" value is the index where you want to start to catch the substring. Have the string "UnitedNations", as a string. I want to extract from there the "Nations" substring. As it's a string itself, I'll want to store it in a string. Then, as a zero-indexed array, the "N" for "Nations" wil be at position 6 (because it's the 7th char), and you'll define the length of your substring in the other field.

As, for the other actions, it might differ from Get String Left, but would work just as the same as Right. The main difference is that Get String Right will start from the char at position 0, and Get String Left will start from the last char, whilst you can have Get Substring starting at any position within the string.

Hope that helps.
Check out our new game: Nitro Chimp. Now live in App Store!

Trailer:
Download: https://itunes.apple.com/app/nitro-chimp/id557150450?l=en&mt=8

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 318
Re: SubStrings
« Reply #2 on: December 05, 2012, 04:44:28 PM »
Thank you very much!  That explanation helps immensely, I really appreciate the detailed writeup.