Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
String manipulation in VFP6
Message
 
To
22/06/2001 12:00:58
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:
00522716
Views:
11
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
Next
Reply
Map
View

Click here to load this message in the networking platform