>I've been trying, unsuccessfully, to do something that I thought I understood... but eventually not...
>
>I have a text file, comma delimited, that i need to import into a table. The problem is the text file is messed up because each line (record) is not necessarily the same number of fields (thanks to the company giving us this data). So, i thought i'd read each line one at a time and parse it inserting commas in the right place. But i've tried low level commands and also tried loading a memo field with the text and parsing that. Neither is working.
>
>with the low level i tried to read each line (to chr(12)+chr(10)), parse and then output each line into a new file. i get the new file but not all the records. and with the memo field i think my problem is the set memowidth command. so here are my questions:
>
>1. When you FOPEN doesn't the file pointer initialize to the beginning of the file?
Yes.
>
>2. FPUTS *does* automatically append a carriage return/line feed doesn't it... is there anything that would cause it not to?
It inserts an operating system defined EOL; under DOS/Win, that's a CR/LF, but unless you made a typo above, a CR/LF pair is CHR(13) + CHR(10).
If you're reading line by line, you're aware that FGETS() accepts a maximum value and reads to the next CR/LF, correct? If no maximum value is specified, a line will be split after 254 bytes; I've used values as large as 8192 for the optional nBytes parameter successfully.
>
>3. How do you set memowidth correctly for a memo field that has many lines, all different lengths?
>
Arbitrarily set it to the largest useful value; under VFP6, the largest useful value is 8192; under VFP5 and earlier, I think that 1024 was the limit.
>I also tried using FILETOSTR and just manipulate the one variable, but VFP kept crashing. The file is about 2.5 MB of text... is there a limit? I thought it would depend on memory, there's 128 MB in this machine.
>
I don't know what to tell you here - I just used FILETOSTR() to pull VFP6.EXE into a memvar with no problem, and it reports a length of 4,192,528 bytes for the variable I read it into. This was under NT 4.0 Build 1381 SP4, with VFP6 version 06.00.8167.00; YMMV.