• Hey! Register here to create your account, engage with the community, and talk about what is new!

How do I get a specific character of a text value and store it in a variable?

Solution
You can use %index(variable name, index). While it's generally used for getting a list value at index, it can also be used to get a specific character at index.
let's say you have a variable called DF Variable and it's equals to [Text]DiamondFire. You can get a text value and name it %index(DF Variable, 8) and it will return an F since the 8th letter in the word DiamondFire is F. However, this does not have handling if the index is out of range, so if you do %index(DF Variable, 12) it will return nothing, and if you put it in a send message even with other stuff, the send message will not send anything, so be careful of that. Another thing is you can replace the number with a %var(variable name) and it should...

ARMcPro

Forum adept
Overlord
Joined
Oct 20, 2020
Messages
1,245
Reaction score
349
You can use %index(variable name, index). While it's generally used for getting a list value at index, it can also be used to get a specific character at index.
let's say you have a variable called DF Variable and it's equals to [Text]DiamondFire. You can get a text value and name it %index(DF Variable, 8) and it will return an F since the 8th letter in the word DiamondFire is F. However, this does not have handling if the index is out of range, so if you do %index(DF Variable, 12) it will return nothing, and if you put it in a send message even with other stuff, the send message will not send anything, so be careful of that. Another thing is you can replace the number with a %var(variable name) and it should handle the index, so if you have a variable called Index Var and it's equals to 6, you can use %index(DF Variable, %var(Index Var)) and it will return the 6th letter which is n.
 
Solution

NPCJerryClick

New member
Joined
Oct 30, 2022
Messages
4
Reaction score
2
You can use %index(variable name, index). While it's generally used for getting a list value at index, it can also be used to get a specific character at index.
let's say you have a variable called DF Variable and it's equals to [Text]DiamondFire. You can get a text value and name it %index(DF Variable, 8) and it will return an F since the 8th letter in the word DiamondFire is F. However, this does not have handling if the index is out of range, so if you do %index(DF Variable, 12) it will return nothing, and if you put it in a send message even with other stuff, the send message will not send anything, so be careful of that. Another thing is you can replace the number with a %var(variable name) and it should handle the index, so if you have a variable called Index Var and it's equals to 6, you can use %index(DF Variable, %var(Index Var)) and it will return the 6th letter which is n.
Thanks!
 
Top Bottom