Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
String manipulation in VFP6
Message
 
To
25/06/2001 13:40:14
Jerry Tovar
Dana Corporation Dana It
Maumee, Ohio, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00522546
Message ID:
00523318
Views:
8
Hi Jerry,

MLINE() treats the spaces as word delimiters and uses them to determine where to break the line. You could do a chrtran() on the string to convert spaces to something else, and then chrtran() back. For example, if you know there won't be any chr(149)s in the file, you could change the following lines (off the top of my head - I'm not sitting at my development machine to test this)
lcWholeFile = <b>chrtran(</b>filetostr('c:\temp\testline.txt')<b>, ' ', chr(149))</b>
...
fputs(lnOutFile, <b>chrtran(</b>mline(lcWholeFile, 1, _mline)<b>, chr(149), ' ')</b>
Cheers,

Andrew

>Andrew,
>
>This solution worked great, however, our text file contains spaces and this routine doesn't like spaces in the string. Other than that, this worked great.
>
>Any idea why MLINE() doesn't like spaces?
>
>Thanks,
>
>Jerryt
>
>
>
>>Don't forget thet VFP has SET MEMOWIDTH - Try something like this:
>>
* create a sample file
>>* with 1000 lines 40 to 119 characters long
>>strtofile('', 'c:\temp\testline.txt')
>>for i = 1 to 1000
>>	strtofile(repl('*', int(rand() * 80) + 40) + chr(13), 'c:\temp\testline.txt', .t.)
>>endfor
>>
>>* read the file into a string
>>local ltStart, ltFileStart, ltFinish
>>ltStart = datetime()
>>lcWholeFile = filetostr('c:\temp\testline.txt')
>>local lnMemoWidth
>>lnMemoWidth = set('memowidth')
>>set memowidth to 80
>>
>>ltFileStart = datetime()
>>_mline = 0
>>*!*	strtofile('', 'c:\temp\testlineout.txt')
>>lnOutFile = fcreate('c:\temp\testlineout.txt')
>>for i = 1 to memlines(lcWholeFile)
>>*!*		strtofile(mline(lcWholeFile, 1, _mline) + chr(13), 'c:\temp\testlineout.txt', .t.)
>>	fputs(lnOutFile, mline(lcWholeFile, 1, _mline))
>>*!*		? mline(lcWholeFile, 1, _mline)
>>endfor
>>fclose(lnOutFile)
>>set memowidth to lnMemowidth
>>ltFinish = datetime()
>>
>>lcMessage = 'Start : ' + tran(ltStart) + chr(13) + 'File Start : ' + tran(ltFileStart) + ' - d1 : ' + tran(ltFileStart - ltStart) + chr(13) + ;
>>	'Finish : ' + tran(ltFinish) + ' - d2 : ' + tran(ltFinish - ltFileStart) + ' - d3 : ' + tran(ltFinish - ltStart)
>>
>>wait wind lcMessage
>>
>>Cheers,
>>
>>Andrew
>>
>>>Using VFP6 SP4
>>>
>>>Are there any article on string manipulation in VFP6?
>>>
>>>I need to write a generic routine to parse any text file into 80 character lines and output these lines into a new text file, for sending up into a mainframe.
>>>
>>>I am currently grabbing the file with the STRTOFILE() into a memvar then I go through each character 1 character at a time to create this file. I also do some other testing but this is the idea.
>>>
>>>However, this technic seems slow, especially on a large text file.
>>>
>>>Any help would be great.
>>>
>>>Thanks,
>>>
>>>Jerryt


If we were to introduce Visual FoxBase+, would we be able to work from the dotNet Prompt?


From Top 22 Developer Responses to defects in Software
2. "It’s not a bug, it’s a feature."
1. "I thought I fixed that."


All my FoxTalk and other articles are available on my web site.


Unless specifically identified otherwise, anthing posted here is purely my opinion and may or may not reflect the policies or practices of Microsoft.
Previous
Reply
Map
View

Click here to load this message in the networking platform