CRLF in Windows OS gives a double space

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
churchken
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 66
Joined: Sun Apr 15, 2007 2:54 pm

CRLF in Windows OS gives a double space

Post by churchken »

Hi,

A ".txt" file, opened with Windows notepad, appears "single-spaced".

But, when that file is "read" into my REV script, using the URL command, and placed into a field, it appears "double-spaced". Then if that field is written to a new .txt file using the URL command, that new file also is "double-spaced" when opened in Windows notepad.

Is there a way to "replace" the CRLF that is causing the double spacing and get single spaced text into the REV field?

Thanks for any ideas.
Ken
malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Contact:

Post by malte »

Hi,

your almost there

replace crlf with cr in fld "myField"

should do the trick.

Hope that helps,

Malte
churchken
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 66
Joined: Sun Apr 15, 2007 2:54 pm

replace CRLF with CR

Post by churchken »

Malte,

Thanks for your quick reply.

I had already tried that replace code, and it did not alter the result.

My OS is windows XP, and this issue seems to be in how REV and the OS interpret the CRLF.

I might add that this is happening on a .txt file that is "written" directly to disk by another program, so I don't know if that program is using an unexpected control character for the CRLF.

Any other ideas?
Ken
BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Post by BvG »

if you mean "all chars have additional spaces" when you say double-spaced, then most likely the original file is unicode of some sorts. I never have used it, but rev has ways to read unicode text.
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
churchken
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 66
Joined: Sun Apr 15, 2007 2:54 pm

double spaced

Post by churchken »

Bvg,

Sorry for the confusion. No, by "double spaced" I meant that each line seems to have 2 CRLF characters. The text on each line has no unwanted spaces within the individual characters. But, after each line, there is a blank line before the next line of text. Here is an example:

2008-07-03,115.953125,6,510,115.953125,115.968750,1978,0,0

2008-07-03,115.953125,12,504,115.953125,115.968750,1976,0,0

2008-07-03,115.953125,1,492,115.953125,115.968750,1974,0,0


The original file is written to disk by a program that takes data directly from a port feed. Perhaps there is some unusual transmission code involved.

Again, thanks for the help.
Ken
malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Contact:

Post by malte »

Hi Ken,

sorry for the confusion. You would need to do the replace before you put the data into the field. Read the URL into a variable replace there and put into a field fterwards. Or do a replace cr&cr with cr on the field or filter the field without empty. There is a few choices to go about this. The reason is, that rev converts lf to cr characters internally when putting data into the field. So for rev it looks like a double cr character instead of lf.

Hope that helps,

malte
churchken
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 66
Joined: Sun Apr 15, 2007 2:54 pm

thanks

Post by churchken »

Malte,

Thanks SO much !

Doing the replace in a variable before putting the result into a field was exactly what worked.

Many thanks.
Ken
Post Reply