>>>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 it's fixed at 80
lcstring = FILETOSTR(lcfilename)
>>lcnewstring = ""
>>lcCF_TEXT = CHR(13) + CHR(10)
>>DO WHILE NOT EMPTY(lcstring)
>> lcnewstring = lcnewstring + lcCF_TEXT + LEFT(lcstring, 80)
>> lcstring = SUBSTR(lcstring, 81)
>>ENDDO
>>lcnewstring = SUBSTR(lcnewstring, 3)
>>= STRTOFILE(lcnewstring, lcnewfile)
Note that this is just off the top of my head and I haven't debugged it.
>
>
>The in comming file is variable length records. Each record is separated by CRLF. So I have to read each character until I my counter reaches 80 then start over on a new line, or until I reach a CRLF then start a new line.
>
>The output will have a maximum of 80 character per line.
>
>I am looking at the FGETS(). Maybe I can process each line one at time.
>
>Thanks,
>
Jerryt,
Then I'd try:
lcstring = FILETOSTR(lcfilename)
DIMENSION a_lines[1]
lnlines = ALINES(a_lines, lcstring)
Then I'd iterate through the array. If the length was 80 or less, output with FPUTS(). If greater than 80, output the fiirst 80 character, then the remainder with FPUTS().
George
Ubi caritas et amor, deus ibi est