开发者

Visual Foxpro writing import files with line feeds

I know line feeds in Foxpro are CHR(10) + CHR(13), but when creating an import record comma delimited, I need to imbed the line feed into the field, when I add the CHR(10) + CHR(13) into the .txt file it puts an actual line feed into the import record rather than being embeded.

Any examples of syntax you can give me:

** This example does not work! can I get an example of how to embed 开发者_Python百科these line feeds correctly? Sam Jenkins + CHR(13) + CHR(10) + Address1 + CHR(13) + CHR(10) + Address2

Thanks - Evan


Maybe I don't understand the ops question but....

ASCII encoding:

CHR(10) = Newline/Linefeed

CHR(13) = Carriage return

Most text file viewers will will move the cursor down one line and to the left margin when they encounter a CHR(13)CHR(10). Your file may be correct, it's just that whatever you are using to view it is respecting the characters. If the text was quote enclosed and the viewer respected that, you might get the display you want otherwise the viewer wouldn't know when a CrLf is embedded or the real end of line.


Sorry, you're not going to get around text files representing linefeed+carriage return as anything other than what they are. I'd suggest some sort of workaround. Maybe you can encode them like C does, "\n" would work fine in VFP and a text file. You'd have to decode it in the consuming application though.

Your specific example seems very strange. If I was writing a comma delimited file, I'd seperate the fields with commas "Name, Addr1, Addr2" instead of lfcr. Then VFP would import that with a simple append from x type csv.

If you're trying to read from a file where the fields are seperated onto different lines, you're going to have to do more work. If you're lucky, the file always uses the same number of fields and you can just count line numbers to know which field you're on. (line 1 is name, line 2 is addr1, line3 addr2, line4 city-state-zip, line5 next name...) If that was the case, I'd use a loop and some local variables and then gather them into a blank table row.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜