# Loading external variables, problem with string to num

**URL:** <https://forum.kirupa.com/t/loading-external-variables-problem-with-string-to-num/2796>\
**Category:** Uncategorized\
**Created:** [April 8, 2002, 6:52pm UTC](https://forum.kirupa.com/t/loading-external-variables-problem-with-string-to-num/2796 "2002-04-08T18:52:46Z")\
**Posts on this page:** 12\
**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:** [April 8, 2002, 6:52pm UTC](https://forum.kirupa.com/t/loading-external-variables-problem-with-string-to-num/2796/1 "2002-04-08T18:52:46Z")

</div>

ok… I really feel like pounding my head against a wall here.\r\rI’m importing variables from a regular txt file. I have dynamic text fields on the main timeline that pick up and show these variables. I know that they are coming into the player at \_root, or \_level0\r\rrows=“5”; is one of them. When I do a debug/List variables, that’s what it shows me.\r\rI do a \rtrace(rows);\rand I get\r"undefined"\r\rI do a\rparseInt(rows);\rand I get \r"NaN"\r\rWhat is it exactly that I can’t get?\r\rA) Why can’t I trace the @#%$ variable?\rsince you should be able to trace anything, and\rB) Why can’t I convert it to a number from the string of “5”?\r\rany clue?? I’m on 5 days of insomnia, and I just can’t figure out what I’m doing wrong…

---

<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:** [April 8, 2002, 7:11pm UTC](https://forum.kirupa.com/t/loading-external-variables-problem-with-string-to-num/2796/2 "2002-04-08T19:11:53Z")

</div>

let’s see your text file. most of the time the problem is there.\ralso, do you have a flag at the end of the text file to let the timeline know that all the text has loaded?\r:) \rjeremy

---

<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:** [April 8, 2002, 7:34pm UTC](https://forum.kirupa.com/t/loading-external-variables-problem-with-string-to-num/2796/3 "2002-04-08T19:34:39Z")

</div>

&date0=2002-04-06%2009%3A17%3A08&name0=administrator&email0=dhaisley%[40centerspin.com](http://40centerspin.com)&[site0=www.centerspin.com](http://site0=www.centerspin.com)&comment0=Well%20no%20matter%20who%20created%20it%2C%20I%27m%20in%20charge…&date1=2002-04-06%2009%3A16%3A11&name1=Upuaut&email1=administrator%[40centerspin.com](http://40centerspin.com)&[site1=www.centerspin.com](http://site1=www.centerspin.com)&comment1=Hey%2C%20get%20the%20hell%20out…%20this%20is%20MY%20creation&date2=2002-04-06%2009%3A12%3A19&name2=David&email2=Upuaut%[40centerspin.com](http://40centerspin.com)&[site2=www.centerspin.com](http://site2=www.centerspin.com)&comment2=Well%2C%20here%27s%20the%20guestbook…%20or%20at%20least%20a%20Beta%20version.%20Please%20sign%20it%20and%20let%20me%20know%20what%20you%20think.&rows=3&flag=true

---

<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:** [April 8, 2002, 8:27pm UTC](https://forum.kirupa.com/t/loading-external-variables-problem-with-string-to-num/2796/4 "2002-04-08T20:27:35Z")

</div>

ok, i got the file to load the variables. here’s what i did.\rframe 1:\rloadVariables (“loadme.txt”, this);\rframe 3:\rif(flag==“true”){\rtrace(“playing through”);\rplay();\r} else {\rtrace(“looping”);\rgotoAndPlay(\_currentframe-1);\r}\rframe 4:\rfor(ii in this){\rif(typeof(ii)==“string”){\rtrace (ii+": "+this[ii]);\r}\r}\rstop();\r\r…\rnow, to convert a string that is a number to a number, i do this:\rrows\*=1;\r\rand i did change the text file for clarity…\rdate0=2002-04-06%2009%3A17%3A08&\r&name0=administrator&\r&email0=dhaisley%[40centerspin.com](http://40centerspin.com)&\r&[site0=www.centerspin.com](http://site0=www.centerspin.com)&\r&comment0=Well%20no%20matter%20who%20created%20it%2C%20I%27m%20in%20charge…&\r&date1=2002-04-06%2009%3A16%3A11&\r&name1=Upuaut&\r&email1=administrator%[40centerspin.com](http://40centerspin.com)&\r&[site1=www.centerspin.com](http://site1=www.centerspin.com)&\r&comment1=Hey%2C%20get%20the%20hell%20out…%20this%20is%20MY%20creation&\r&date2=2002-04-06%2009%3A12%3A19&\r&name2=David&\r&email2=Upuaut%[40centerspin.com](http://40centerspin.com)&\r&[site2=www.centerspin.com](http://site2=www.centerspin.com)&\r&comment2=Well%2C%20here%27s%20the%20guestbook…%20or%20at%20least%20a%20Beta%20version.%20Please%20sign%20it%20and%20let%20me%20know%20what%20you%20think.&\r&rows=3&\r&flag=true\r\ryou can put line breaks in your txt file if you put an amphersand at the end of the line.\r\rhope that helps.\r:)\rjeremy

---

<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:** [April 8, 2002, 8:42pm UTC](https://forum.kirupa.com/t/loading-external-variables-problem-with-string-to-num/2796/5 "2002-04-08T20:42:21Z")

</div>

yup… the only reason I format it like that is it is the way my php returns it.\r\rI’m unclear on something though.\r\rThe trace function I really could care less if I get to work… I hardly ever use it, which is why I don’t really have a good understanding of it yet. (I use text fields which display various info and then I just delete that layer when I have everything working.🙂 )\r\rThe important part of this though is the conversion.\r\rwhy would rows\*=1 return a numerical value if it’s a string?\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:** [April 8, 2002, 8:46pm UTC](https://forum.kirupa.com/t/loading-external-variables-problem-with-string-to-num/2796/6 "2002-04-08T20:46:15Z")

</div>

Well… it works… that’s all I really care about… I’d still like to know why it does.\r\rThanks for the help. Much appreciation

---

<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:** [April 8, 2002, 8:52pm UTC](https://forum.kirupa.com/t/loading-external-variables-problem-with-string-to-num/2796/7 "2002-04-08T20:52:03Z")

</div>

OMG!!!\r\rok, never mind… you want to know what I was doing wrong? It had nothing to do with the variables at all. The problem was in my loop\r\rif (hub.flag==“true”){\r&nbsp &nbsp &nbsp &nbsp gotoAndPlay(4);&nbsp &nbsp &nbsp &nbsp \r}\r\rwas set to\r\rif (hub.flag=true){\r&nbsp &nbsp &nbsp &nbsp gotoAndPlay(4);&nbsp &nbsp &nbsp &nbsp \r}\r\r:) \r\rI’m an idiot\r\rThe reason this screwed up the trace was, I was tracing code that couldn’t exicute because the variables hadn’t loaded yet… as a flag=true statement will simply send that playhead onto frame 4 without even pausing.\r\rOr at least that’s what I believe was the problem as it is the only thing that I changed and now parseInt(); works like it’s supposed to.\r\rJesus I can be dumb when I’m tired.

---

<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:** [April 8, 2002, 9:10pm UTC](https://forum.kirupa.com/t/loading-external-variables-problem-with-string-to-num/2796/8 "2002-04-08T21:10:43Z")

</div>

dont feel bad upu, i’m dumb all the time.

---

<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:** [April 8, 2002, 9:14pm UTC](https://forum.kirupa.com/t/loading-external-variables-problem-with-string-to-num/2796/9 "2002-04-08T21:14:29Z")

</div>

Don’t say that, Jubby. You’re just… different, that’s all.\r\rpom :lol:

---

<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:** [April 8, 2002, 11:36pm UTC](https://forum.kirupa.com/t/loading-external-variables-problem-with-string-to-num/2796/10 "2002-04-08T23:36:04Z")

</div>

anyways…\rtrace just displays what you tell it to in the output window.\rexample:\rtrace(“hello”);\rif you put that in a movie and tested it the output window would show ‘hello’.\ri use trace a lot, and often create a function to trace sets of variables when they change.\r:) \rjeremy

---

<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:** [April 8, 2002, 11:56pm UTC](https://forum.kirupa.com/t/loading-external-variables-problem-with-string-to-num/2796/11 "2002-04-08T23:56:27Z")

</div>

how would you do that because yesterday i was trying to follow my variables while doing that Text animation and i couldn’t do it…

---

<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:** [April 9, 2002, 5:05am UTC](https://forum.kirupa.com/t/loading-external-variables-problem-with-string-to-num/2796/12 "2002-04-09T05:05:19Z")

</div>

I would suspect that you either “loop” your trace function, or place it in a bunch of places throughout your code.\r\rMy problem with trace, I think, was two fold.\r\rA) I was not getting all the variables by the time the trace was called, and\rB) I was trying to trace the parseInt(); function which could not read the number anyway.\r\rIt was something like this\r\rtopStack=parseInt(rows)-1;\r\rDoes anyone know if that looks wrong? I was thinking that maybe it should be\r\rtopStack=(parseInt(rows))-1;\r\rwould it make any difference which way I did that?
