Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sun Jun 24, 2018 3:27 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Mac EndOfLine
PostPosted: Mon Dec 10, 2012 12:32 pm 
Offline

Joined: Mon Mar 10, 2008 2:08 pm
Posts: 42
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
 Profile  
Reply with quote  
 Post subject: Re: Mac EndOfLine
PostPosted: Mon Dec 10, 2012 1:38 pm 
Offline
User avatar

Joined: Mon Feb 05, 2007 5:21 pm
Posts: 600
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
 Profile  
Reply with quote  
 Post subject: Re: Mac EndOfLine
PostPosted: Mon Dec 10, 2012 3:49 pm 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
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
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: Mac EndOfLine
PostPosted: Mon Dec 10, 2012 4:00 pm 
Offline
User avatar

Joined: Mon Feb 05, 2007 5:21 pm
Posts: 600
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
 Profile  
Reply with quote  
 Post subject: Re: Mac EndOfLine
PostPosted: Mon Dec 10, 2012 4:08 pm 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
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
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: Mac EndOfLine
PostPosted: Mon Dec 10, 2012 4:17 pm 
Offline
User avatar

Joined: Mon Feb 05, 2007 5:21 pm
Posts: 600
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
 Profile  
Reply with quote  
 Post subject: Re: Mac EndOfLine
PostPosted: Mon Dec 10, 2012 4:23 pm 
Offline

Joined: Mon Mar 10, 2008 2:08 pm
Posts: 42
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
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group