New topic: Mac EndOfLine
<http://forums.realsoftware.com/viewtopic.php?t=46193> Page 1 of 1 [ 7 posts ] Previous topic | Next topic Author Message bigT Post subject: Mac EndOfLinePosted: Mon Dec 10, 2012 12:32 pm Joined: Mon Mar 10, 2008 2:08 pm Posts: 39 Have program that splits a text file of the 50 states using EndOfLine - works fine in Carbon; BUT just tried to run in Cocoa and the EndOfLine seems to be ignored after the first item is obtained. Is there a workaround? TIA, Tony _________________ Dr. A. J. Marino, Ph.D. MAC OSX 10.7.5; RB2012 R1.2 Professional Top ktekinay Post subject: Re: Mac EndOfLinePosted: Mon Dec 10, 2012 1:38 pm Joined: Mon Feb 05, 2007 5:21 pm Posts: 306 Location: New York, NY // Assume txt has the data txt = ReplaceLineEndings( txt, EndOfLine.Macintosh ) dim arr() as string = txt.Split( EndOfLine.Macintosh ) I haven't tried this to see if there is really a bug that has be dealt with. _________________ Kem Tekinay MacTechnologies Consulting http://www.mactechnologies.com/ Need to develop, test, and refine regular expressions? Try RegExRX. Top DaveS Post subject: Re: Mac EndOfLinePosted: Mon Dec 10, 2012 3:49 pm Joined: Sun Aug 05, 2007 10:46 am Posts: 4331 Location: San Diego, CA remember... endOfLine.Macintosh is NOT the Apple OSX default line terminator!!! That is the line terminator for OS9 and before. the OSX line terminator is endOfLine.UNIX MacIntosh = 0x0D Unix = 0x0A Windows =0x0A0D _________________ Dave Sisemore MacPro, OSX Lion 10.7.4 RB2012r1 Note : I am not interested in any solutions that involve custom Plug-ins of any kind Top ktekinay Post subject: Re: Mac EndOfLinePosted: Mon Dec 10, 2012 4:00 pm Joined: Mon Feb 05, 2007 5:21 pm Posts: 306 Location: New York, NY To be clear, Dave means for files created by the OS, outside the Real Studio environment, and he's right. Within RS, EndOfLine returns chr( 13 ) in both Carbon and Cocoa. That's why I added the call to "ReplaceLineEndings", so you know exactly what you're dealing with before calling Split. FYI, my M_String module has an EndOfLineOf function that will quickly identify the EOL character of a string, so you could do: dim eol as string = M_String.EndOfLineOf( txt, EndOfLine ) // The second parameter is optional and is the default if no EOL character is found ; in this case, it doesn't matter what it is, as long as it's something dim arr() as string = txt.Split( eol ) _________________ Kem Tekinay MacTechnologies Consulting http://www.mactechnologies.com/ Need to develop, test, and refine regular expressions? Try RegExRX. Top DaveS Post subject: Re: Mac EndOfLinePosted: Mon Dec 10, 2012 4:08 pm Joined: Sun Aug 05, 2007 10:46 am Posts: 4331 Location: San Diego, CA or wrap it all up so you never have to worry about it arr() = split(replacealllineendings(txt,endofline.unix),endofline.unix) _________________ Dave Sisemore MacPro, OSX Lion 10.7.4 RB2012r1 Note : I am not interested in any solutions that involve custom Plug-ins of any kind Top ktekinay Post subject: Re: Mac EndOfLinePosted: Mon Dec 10, 2012 4:17 pm Joined: Mon Feb 05, 2007 5:21 pm Posts: 306 Location: New York, NY Just as a counterpoint, I wouldn't do that since combination lines like that don't buy you anything in performance, and make it harder to read and debug. But you can also write it like this: arr() = ReplaceLineEndings( txt, EndOfLine.UNIX ).Split( EndOfLine.UNIX ) _________________ Kem Tekinay MacTechnologies Consulting http://www.mactechnologies.com/ Need to develop, test, and refine regular expressions? Try RegExRX. Top bigT Post subject: Re: Mac EndOfLinePosted: Mon Dec 10, 2012 4:23 pm Joined: Mon Mar 10, 2008 2:08 pm Posts: 39 Thanks for the assist. Will try various and let you know which I actually use. Tony _________________ Dr. A. J. Marino, Ph.D. MAC OSX 10.7.5; RB2012 R1.2 Professional Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 7 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
