6 Replies Latest reply on Jul 8, 2007 7:34 AM by

    LoadVars confusion

      I'm attempting to call data from a text file with loadVars line-by-line into an array and then display it in tabs to give it the appearance of a borderless table in my textbox. I'm not sure if this is the most efficient way of doing this or if it's even possible but I've been at it far too long to give up. I need to use loadVars so I can update easily in the future and assigning a variable to each line in the text file would mean having to renumber all the lines every update - no good.

      EDIT: My text file looks like this:

      so on
      and so forth

      Thanks a ton in advance for any help on this matter... My code thus far is:

        • 1. Re: LoadVars confusion
          Greg Dove Level 4
          Where you have

          var roster:Array = this.Convocation;

          I can't see how this.Convocation can be anything other than a String.

          To make it an array of lines, you need to split at the linebreaks if that's the separator you want to use in your text file.
          var roster:Array = this.Convocation.split("\r");

          There's also another option if you don't want to do it with &Convocation= etc
          You can just use plain text if you prefer. Have a read through this -

          http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=15&catid=288&threadid =1280364
          • 2. Re: LoadVars confusion
            GWD, Thanks for your quick help!

            Using the .split method worked great in organizing my data into an array. The only problem I have left are the line breaks.

            Is there a way to delete a linebreak when displaying each string of data so it would display correctly? Like this:

            ADetails.text += (Backspace)+"\t"+roster ;
            • 3. LoadVars confusion
              Greg Dove Level 4
              I think there may be a problem with the way linebreaks are represented on different systems.

              before you do the split try doing this:
              //convert CRLF to CR (windows)
              //convert LF to CR (can't remember which OS's use LF only)
              //split at CR
              var roster:Array = this.Convocation.split("\r");
              1 person found this helpful
              • 4. LoadVars confusion
                I'm not entirely certain if it worked. It displayed right the first time but came up as "undefined" at each tab. I hope that tells you something.

                EDIT: NVM, I take that back entirely. Everything "attaches" so to speak and it works great =)

                All I have to figure out now is where to put the line break code when I actually want one!

                Thanks for all your help!!
                • 5. Re: LoadVars confusion
                  Greg Dove Level 4
                  Good to hear.


                  All I have to figure out now is where to put the line break code when I actually want one!

                  If you're using the linebreaks in the source as your separators for 'tab' marking then that's an issue that's easily overcome.
                  Just have a marker sequence that represents the split between your lines in the output text (e.g. [newline], and split to an array at that level first. Then you have an array of elements where each element needs to be split via the "\r" as above.

                  If you read the other link I posted earlier it will give you some ideas
                  1 person found this helpful
                  • 6. Re: LoadVars confusion
                    I'll check it out. Thanks.

                    I was thinking a columns variable myself with a loop to line break after every few lines as needed. Viola, fake table.