# How to select Characters From a String

**URL:** <https://forum.choiceofgames.com/t/how-to-select-characters-from-a-string/5309>\
**Category:** ChoiceScript Help\
**Created:** [September 19, 2014, 1:12am UTC](https://forum.choiceofgames.com/t/how-to-select-characters-from-a-string/5309 "2014-09-19T01:12:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![SLVRWINGS](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/slvrwings/32/112275_2.png) [@SLVRWINGS](https://forum.choiceofgames.com/u/SLVRWINGS)\
**Post date:** [September 19, 2014, 1:12am UTC](https://forum.choiceofgames.com/t/how-to-select-characters-from-a-string/5309/1 "2014-09-19T01:12:11Z")

</div>

I know most programming languages have a function where you can pull individual characters out of a string. for example if I had a first name and wanted to know the first initial, what could I do?

\*create name “John”

\*create initial " "

\*comment I would like to have something like

\*set initial “${John}[1]”

\*comment and have it print

${initial} = J

is there anything like that in ChoiceScript? It would play a pretty significant role in my concept for a game… I would really appreciate it!

---

<div class="post-metadata">

**Author:** ![RETowers](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/retowers/32/21477_2.png) [@RETowers](https://forum.choiceofgames.com/u/RETowers)\
**Post date:** [September 19, 2014, 1:21am UTC](https://forum.choiceofgames.com/t/how-to-select-characters-from-a-string/5309/2 "2014-09-19T01:21:26Z")

</div>

Unfortunately, no, there is no breaking up strings in ChoiceScript.

---

<div class="post-metadata">

**Author:** ![SLVRWINGS](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/slvrwings/32/112275_2.png) [@SLVRWINGS](https://forum.choiceofgames.com/u/SLVRWINGS)\
**Post date:** [September 19, 2014, 1:23am UTC](https://forum.choiceofgames.com/t/how-to-select-characters-from-a-string/5309/3 "2014-09-19T01:23:34Z")

</div>

Well that’s disappointing but I really appreciate your prompt reply! Time to start getting creative I guess…

---

<div class="post-metadata">

**Author:** ![dfabulich](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/dfabulich/32/198373_2.png) [@dfabulich](https://forum.choiceofgames.com/u/dfabulich)\
**Post date:** [September 19, 2014, 1:35am UTC](https://forum.choiceofgames.com/t/how-to-select-characters-from-a-string/5309/4 "2014-09-19T01:35:59Z")

</div>

What did you want to do with this technique?

---

<div class="post-metadata">

**Author:** ![SLVRWINGS](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/slvrwings/32/112275_2.png) [@SLVRWINGS](https://forum.choiceofgames.com/u/SLVRWINGS)\
**Post date:** [September 19, 2014, 4:35am UTC](https://forum.choiceofgames.com/t/how-to-select-characters-from-a-string/5309/5 "2014-09-19T04:35:15Z")

</div>

well I wanted to create a story where the reader could choose one of several characters to accomplish an objective and track that characters stats separately. I was hoping to do so by creating variables such as armor\_1 armor\_2 and so on. If the reader decided he wanted to send character 1 on the mission then I wanted to be able to affect the variables accordingly.

for example, if the user sent char\_1, who has his own strengths and weaknesses, to defend a bridge I could create a quick command to retrieve the 6th character in the string and make it a temp variable. then I could drop it into other variable using commands such as

armor\_[temp variable] or health\_[temp variable] which would then affect armor\_1 or armor\_2 or 3 respectively.

this would allow a deeper level of tactics where the reader has to get to know his characters and make decisions on when to use one vs the others without crutching on one too much.

hopefully I’m not showing my ignorance too much…

---

<div class="post-metadata">

**Author:** ![dfabulich](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/dfabulich/32/198373_2.png) [@dfabulich](https://forum.choiceofgames.com/u/dfabulich)\
**Post date:** [September 19, 2014, 4:54am UTC](https://forum.choiceofgames.com/t/how-to-select-characters-from-a-string/5309/6 "2014-09-19T04:54:13Z")

</div>

Oh, that’s much easier than what you requested. You asked to remove the first letter of the word “John” to get a “J,” but you just want to glue two known variables together.

For that, you can use the `*setref` command and curly parentheses, defined in the [Advanced Choicescript](https://www.choiceofgames.com/make-your-own-games/choicescript-advanced/) guide.

```
*setref "armor_${number}" %+70
*set current_armor {"armor_${number}"}
Your armor_${number} = ${current_armor}
```

---

<div class="post-metadata">

**Author:** ![SLVRWINGS](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/slvrwings/32/112275_2.png) [@SLVRWINGS](https://forum.choiceofgames.com/u/SLVRWINGS)\
**Post date:** [September 19, 2014, 5:18am UTC](https://forum.choiceofgames.com/t/how-to-select-characters-from-a-string/5309/7 "2014-09-19T05:18:08Z")

</div>

That is very easy! Thank you so much for taking the time to help me out! I’m brand new at this so my mind couldn’t fathom more than one way to do that.

I figured it would be easier to explain through the john example…knowing what I know now however… : )
