# Convert To String

**URL:** <https://forum.kirupa.com/t/convert-to-string/3426>\
**Category:** programming\
**Created:** [January 29, 2002, 7:08pm UTC](https://forum.kirupa.com/t/convert-to-string/3426 "2002-01-29T19:08:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [January 29, 2002, 7:08pm UTC](https://forum.kirupa.com/t/convert-to-string/3426/1 "2002-01-29T19:08:40Z")

</div>

I load variables from a text file named :\r\r&first1=John\r&first2=Mark\r&first3=Tim\r&first4=Mike\r\rI am evaluating them in a loop by constructing the variable I want to test and assigning it the value of first1, first2, etc. based on the current loop iteration\r\rFor Example, during iteration start\_num=1 :\r\r test\_first = “first”;\r test\_first = test\_first.concat(start\_num);\r run\_first = eval (test\_first);\r\rThis makes the variable I want to test, run\_test, and assigns it the value of, first1, which is John. So :\r\r run\_test=John\r\rHowever, I am comparing, run\_test, to a input from a text box, text\_input. text\_input is type string, but run\_test is type undefined.\r\rHow do I convert the variable run\_test to a string so I can evaluate it in an IF statement?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [January 29, 2002, 8:23pm UTC](https://forum.kirupa.com/t/convert-to-string/3426/2 "2002-01-29T20:23:28Z")

</div>

in the script you’ve posted, there’s no point where you assign anything to run\_test, which would explain why it’s undefined. ; )\r\ryou have assigned run\_first, is that meant to be the assignation?\r\rpotential typos aside, variables from txt files are strings by default there’s nothing you’re doing to change the data type so all your data here is a string.\r\rif you want to be absolutely sure, to convert data to a string is:\r\rString(data);\r

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [January 31, 2002, 6:53am UTC](https://forum.kirupa.com/t/convert-to-string/3426/3 "2002-01-31T06:53:34Z")

</div>

although you don’t have to initiate variables in flash, i find that it is still a good idea.\ri pick a frame near the beginning of the timeline and declare EVERY variable that is used throughout movie and put a description of what the variable is/does.\rexample:\r// string for input text box\rsMyString="";\r// that’s it.\r\rnow if you do this:\rtrace typeof(sMyString);\r\rit will return “string” in the output window. if you do the same trace without initializing the output window will be empty.\r:) \rjeremy
