Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Filling a text variable with lines ending with cr/lf.
Message
From
06/04/2000 02:17:36
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
04/04/2000 09:20:18
Michael Dougherty
Progressive Business Publications
Malvern, Pennsylvania, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00354764
Message ID:
00356118
Views:
19
>>Joe,Only chr(13) would be sufficient.
>
>That's true for the purpose of the editbox, but if you write that string to a file (StrToFile) then without the chr(10) the CR shows up as a black square in a simple editor like Notepad. Without testing the editbox, if it displays correctly using CRLFs, I'd use them because it'll be that much easier to output the strings to a text file. (guessing that the editbox value is stored in a memo field which might be dumped to a text file)
>
>If the editbox is used primarily for display only, it might make the code easier to read to not have all the extra chr(10).
>
>Joe, i usually make a CRLF variable:
>CRLF = chr(13) + chr(10)
>textline = "Line1" + CRLF + "Line2" + CRLF + CRLF + "Line4" [+ etc.]
>If you later wanted to change your 'line-end' characters, you change only the CRLF variable...


Michael,
Actually I wrote a long reply first but before sending cut the rest thinking this was an editbox thing only :)
If it's for something else then not only chr(10) but performance comes into play. I would first write to a lowlevel file than read from there. This seem to be a dummy thing to do but as linecount increases the speed difference is enormous. Here is what I mean with a rough and simple test code :
#define NL chr(13)+chr(10)
#define LINECOUNT 1000000
create cursor myDummy (dummy c(10))
for ix = 1 to LINECOUNT
    insert into mydummy values (sys(2015))
endfor
start = seconds()
_Plain()          && Try this version during a coffee break :)
? seconds()-start
start = seconds()
_lowlevel()
? seconds()-start


function _lowlevel
#define MAX_WIDTH 65535
local lcTempFile, handle, lnSize, cContent
lcTempFile = sys(2015)+".tmp"
handle = fcreate(lcTempFile)
scan
  =fputs(handle,dummy,MAX_WIDTH)
endscan
lnSize=fseek(handle,0,1) && Get size
=fseek(handle,0,0) && Rewind to top
cContent=fread(handle,lnSize)
=fclose(handle)
erase (lcTempFile)
return cContent

function _Plain
local cContent
cContent = ""
scan
	cContent = cContent + dummy + NL
endscan
return cContent
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform