How to check different parts of a Game variable?

How can i check specific parts of whats saved inside a game variable?

For example:
I've a part in my game where player can write things(Everything written is saved in a variable). If he write something like "Text_Show Hi" how could i check it the first part(Text show) And then whats written in the second part ( Hi ) in order to make it show "Hi" in a message box? Is there a way to do that using "Conditional Branch"?
For checking if the thing starts with something, do a conditional branch script command:
Code:
$gameVariables.value(VARIABLEID).startsWith("Text show")

The second part is a bit more complicated, you'll probably need to do some script stuff like replacing the value of the variable:

Code:
$gameVariables.setValue(VARIABLEID, $gameVariables.value(VARIABLEID).slice("Text show".length - 1))

Can't test anything right now but let me know how this works for you!
For checking if the thing starts with something, do a conditional branch script command:
Code:
$gameVariables.value(VARIABLEID).startsWith("Text show")

The second part is a bit more complicated, you'll probably need to do some script stuff like replacing the value of the variable:

Code:
$gameVariables.setValue(VARIABLEID, $gameVariables.value(VARIABLEID).slice("Text show".length - 1))

Can't test anything right now but let me know how this works for you!
Worked perfectly! Thank you! I just had to add an espace in the second code, after "Text show" to be "Text show " (because for some reason it showed the T in the end[Actually i used "show_text" instead of "Text show" thats why]).

Let me just ask if I understand it correctly: First part checks the beginning of the variable, if it be the same of whats written, it returns True. The second part removes that part from the Variable, allowing me to read what comes after that.

Using it I can "cut" the variable in many parts can't I?

Also, what if I want to get something like random numbers inside it? For example: "Spawn 2 33", then it spawns something at X=2 and Y=33.
I can use what you said to get the command "Spawn", but how can I get random information(That i can't list, since it could give me infinite amounts of If and Else to work with) using spaces to separate?
I just had to add an espace in the second code, after "Text show" to be "Text show "
Ah, actually, to fix the text show thing just remove the "- 1", I miscounted. So:

Code:
$gameVariables.setValue(VARIABLEID, $gameVariables.value(VARIABLEID).slice("Text show".length))

Your thoughts are correct, though there's easier ways for getting stuff in a list like that other than slice.

This would get the integer value of a given thing:
Code:
parseInt($gameVariables.value(VARIABLEID).split(" ")[INDEX])
where something with
"Spawn 2 33"

Having index be 0 would give "Spawn", 1 would be "2", 2 would be "33". Since there's a parseInt only index 1 and 2 would be valid since spawn isn't an integer.
Thank you so much for the help!
I know this post is older(A BIT) than a month but I've another question inside this same topic.

Let's say I want to write a Text, followed by a Number and then another text. Something like this:

write_text 5 Yo world!

How do I check what comes AFTER the number(No matter how many digits there are) to save it in a variable?

I tried both

Code:
$gameVariables.setValue(16 + $gameVariables.value(16), $gameVariables.value(13).slice("write_JS ".length + $gameVariables.value(16).length + " ".length));

And

Code:
$gameVariables.setValue(16 + $gameVariables.value(16), $gameVariables.value(13).slice("write_JS " + $gameVariables.value(16) + " ".length));
(Variable 13 stores the whole sentence, 16 stores the "ID" number of that comes after write_text[I use it to convert ID of text to VariableID in MV])
None work.


EDIT:
Actually, as always, I found the answer myself after asking:
Code:
$gameVariables.setValue(16 + $gameVariables.value(16), $gameVariables.value(13).slice(("write_JS " + $gameVariables.value(16)).length+1));
Thread closed IgnoreMe

Original thread: https://forums.rpgmakerweb.com/threads/how-to-check-different-parts-of-a-game-variable.91261/