loadVars( ) and line breaks, trouble

I thought I had compensated for all the weird ways to do line breaks for Macs and PCs...  But apparently NOT !

The code below works fine in the Flash 8 Pro IDE, also works fine when run in Safari, Firefox and IE on a Mac (as LOCAL FILES), but does NOT work when uploaded and run in Safari, Firefox or IE from the internet....

The code below reports that only ONE line has been read into the array
from the file at ---
   http://www.armchair-travel.com/vt/105_Hospitality/descr.txt

 I know there are 53 lines in the file....

What am I doing wrong, please ?

===============================


var loadFile = new LoadVars();
loadFile.onData = function(theDescr:String) {  // called when data file is Completely Loaded
      var theLines:Array;
      // Split either Mac or PC formatted descr.txt files into separate lines
      theDescr = String(theDescr).split("\r\n").join("\r");
      //
      theDescr = theDescr.split("\t").join("");    // remove tabs
      theLines = String(theDescr).split("\r");  // break into lines
      //
      statusField.text = "descr.txt: " + theLines.length + " lines loaded."
.....
...
..

}


DonelsonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Aneesh ChopraCommented:
Issue is in the following line
----------
 theLines = String(theDescr).split("\r");  // break into lines
--------------

you should use "\n" here..
-----------
 theLines = String(theDescr).split("\n");  // break into lines
----------

Rgds
Aneesh
0
Aneesh ChopraCommented:
Problem is :

following line of code not working actually.
(you can remove this line of code... it is doing nothing.)
----------
 theDescr = String(theDescr).split("\r\n").join("\r");
----------

flash does not get "\r\n" to split... that so it has nothing to join using "\r"...


0
DonelsonAuthor Commented:
When I use your suggestions, then the program does not work on local machines.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Aneesh ChopraCommented:
Use the following code it will work for both
----------
var loadFile = new LoadVars();
loadFile.onData = function(theDescr:String) {  // called when data file is Completely Loaded
     var theLines:Array;
     // Split either Mac or PC formatted descr.txt files into separate lines
     theDescr = String(theDescr).split("\r\n").join("\n");
     //
     theDescr = theDescr.split("\t").join("");    // remove tabs
     theLines = String(theDescr).split("\n");  // break into lines
     //
     statusField.text = "descr.txt: " + theLines.length + " lines loaded."
.....
...
..

}
-------------

here if text has "\r\n" replace it with "\n" and later we are spliting the lines with" \n"

Rgds
Aneesh

0
DonelsonAuthor Commented:
When I load the file Locally on the Mac, the line break is charCode 0x0d (13).

When I load the file via the internet (on the Mac), the line break char code is 0x0a (10).

What kind of BULLSHT is that !???  

What kind of brain damage switches chars around in a file differently between Local Access and Internet Access ?

0
DonelsonAuthor Commented:

-- "here if text has "\r\n" replace it with "\n" and later we are spliting the lines with" \n"

Does not work on Mac. Mac uses only 0x0d.
0
Aneesh ChopraCommented:
It may depend on server, how server parse a normal text file..
anyway just look for solution to your problem,

My above suggestion will work fine for both...

Rgds
Aneesh
0
Aneesh ChopraCommented:
ok then here the solution
----------
var loadFile = new LoadVars();
loadFile.onData = function(theDescr:String) {  // called when data file is Completely Loaded
     var theLines:Array;
     // Split either Mac or PC formatted descr.txt files into separate lines
     theDescr = String(theDescr).split("\r\n").join("\r");
     theDescr = String(theDescr).split("\n").join("\r");
     //
     theDescr = theDescr.split("\t").join("");    // remove tabs
     theLines = String(theDescr).split("\r");  // break into lines
     //
     statusField.text = "descr.txt: " + theLines.length + " lines loaded."
.....
...
..

}
--------------

replace "\r\n" with "\r",
then replace existing "\n" with also "\r"

and split the lines now using "\r"

Rgds
Aneesh
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DonelsonAuthor Commented:
This works now ---
==============


            // Split either Mac or PC formatted descr.txt files into separate lines
            theDescr = theDescr.split("\r\n").join("\n");
            theDescr = theDescr.split("\r").join("\n");
            //
            theDescr = theDescr.split("\t").join("");    // remove tabs
            theLines = theDescr.split("\n");  // break into lines
            //
==============

What a load of horse droppings !!!

Thanks, for your help, Aneesh.

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.