7 Replies Latest reply on Feb 26, 2009 5:54 PM by flexstone

    declare variable

      i got warning after execute this code.
      it says that line variable has no type declaration.
      what should i do? this is the code-->
        • 1. Re: declare variable
          fusi0n89
          Just a quick look but you never gave a type to line were you looking for:
          for each (var line:String in myText.text.split("\n"))
          1 person found this helpful
          • 2. Re: declare variable
            so
            what should i do?
            can u give the example?
            • 3. Re: declare variable
              fusi0n89 Level 1
              I already showed you, your code:
              for each (var line in myText.text.split("\n"))
              my code:
              for each (var line:String in myText.text.split("\n"))
              1 person found this helpful
              • 4. Re: declare variable
                hahaha.
                i didnt realize its actually different.
                thank you.
                erm
                but it still shows its warning says the same thing
                whats wrong in mycode??
                • 5. Re: declare variable
                  flexstone Level 1
                  I suggest you break it down and focus on creating the array of lines before trying to move on like so

                  var myText:String = myText.text
                  var myTextArr = myText.toString().split(/[\r\n]/g)
                  trace(myTextArr.length) // should give you a count of all the lines...


                  /[\r\n]/g - is a regular exp that looks for every new line character in the string that was created programmatically using \r to represent new line

                  You can also try variations of the regExp until you get the line count you expect.

                  /[\r\n]{1,2}/g - looks for a minimum of 1 and a maximum of 2 line breaks

                  As a newbie you have a hard slog ahead of you, I know it can get frustrating but trial and error is the only way and google search for examples. There are sample of parsing weblogs out there already written too, Many developers are will to help but few don't have time to write the code for you. I suggest you read about Regular Expressions too they are a vital part of any programmers repertoire
                  • 6. Re: declare variable
                    thank you flexstone..

                    okey, now i want to really scope..
                    can u help me to give me the complete programming in-->exp:
                    myText.text: 1)saya suke awak
                    2)saya benci awak

                    how to split "saya", "suke" and "awak" into one column each of them.
                    then, how to make sure this split process also occur at "saya benci awak" and so on..
                    i really hope u can give me the simple complete programming about it (<-- for u) to me?
                    i want to study this based on your example.
                    i know its easy to u..
                    really need your help.
                    thank you.



                    • 7. Re: declare variable
                      flexstone Level 1
                      After all the help, examples and references already given here and freely available all over the web, you are still struggling, I am sorry to say I don't think you are cut out for programming. If you insist on continuing, seek out someone in your native language to help you.
                      1 person found this helpful