# How To: List/Array in Choicescript v4.1

**URL:** <https://forum.choiceofgames.com/t/how-to-list-array-in-choicescript-v4-1/28640>\
**Category:** Game Development\
**Created:** [July 12, 2017, 6:10am UTC](https://forum.choiceofgames.com/t/how-to-list-array-in-choicescript-v4-1/28640 "2017-07-12T06:10:20Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![HWKEye](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/hwkeye/32/31852_2.png) [@HWKEye](https://forum.choiceofgames.com/u/HWKEye)\
**Post date:** [August 15, 2022, 9:18am UTC](https://forum.choiceofgames.com/t/how-to-list-array-in-choicescript-v4-1/28640/25 "2022-08-15T09:18:11Z")

</div>

You might want to take a look at this, I know it has an array function.

> [@toolbox \[TOOL\] CSLIB - ChoiceScript Library](https://forum.choiceofgames.com/t/tool-cslib-choicescript-library/100950):
>
> [[banner]](https://github.com/ChoicescriptIDE/cslib) A compass for the maze. Hi all! @cjw, @choicehacker, and I would like to introduce to you CSLIB v0.1! gem CSLIB is a high-quality collection of helpful routines/functions (known collectively as a “library”) for ChoiceScript. gem CSLIB aims to add a whole host of new functionality to ChoiceScript via \*gosub\_scene calls, for e.g.: \*gosub\_scene cslib\_string reverse “Hello World!” ${cslib\_ret} = !dlroW olleH [[direct-link download button]](https://github.com/ChoicescriptIDE/cslib/releases)play_buttonsparkles Featuresplay_buttonglowing_star Installation Instructio…

---

<div class="post-metadata">

**Author:** ![cup\_half\_empty](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/cup_half_empty/32/273983_2.png) [@cup\_half\_empty](https://forum.choiceofgames.com/u/cup_half_empty)\
**Post date:** [August 15, 2022, 9:56am UTC](https://forum.choiceofgames.com/t/how-to-list-array-in-choicescript-v4-1/28640/26 "2022-08-15T09:56:36Z")

</div>

CS Lib has helper subroutines for working with arrays. It still requires you to instanciate all the variables.

Your solution reminded me of @Twiger_Fluff’s one, so you might want to check that one as well.

> [@How To: List/Array in Choicescript v4.1](https://forum.choiceofgames.com/t/how-to-list-array-in-choicescript-v4-1/28640):
>
> Alright, so you can make lists in choicescript using the \*script command and whatnot, but that will make it hard/impossible to get your game published (So I've heard). That is why I made this code. It uses just a few variables to: -make an unlimited number of lists with unlimited length -add items to lists -read any item from the list, ie the first item or the twentieth item, etc -replace an item in the list with something new, no hassle -deleting an item in a list by index (aka deleting item on…

---

<div class="post-metadata">

**Author:** ![CJW](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/cjw/32/111787_2.png) [@CJW](https://forum.choiceofgames.com/u/CJW)\
**Post date:** [August 15, 2022, 12:23pm UTC](https://forum.choiceofgames.com/t/how-to-list-array-in-choicescript-v4-1/28640/27 "2022-08-15T12:23:50Z")

</div>

Unfortunately, as you say, even with CSLIB you’d need to define your “maximum” amount of variables. There is no such thing as dynamically growing arrays in ChoiceScript.

Both your solution and @Twiger_Fluff’s get around this by using strings as the storage medium.

I’m going to merge this thread into Twiger’s thread (as that solution came along first). It’s good to have another reference implementation though, thank you for sharing.

[Previous page](https://forum.choiceofgames.com/t/how-to-list-array-in-choicescript-v4-1/28640.md?page=1)
