Visual Foxpro 使用换行符编写导入文件

发布于 2024-10-15 05:26:48 字数 279 浏览 8 评论 0原文

我知道 Foxpro 中的换行符是 CHR(10) + CHR(13),但是在创建以逗号分隔的导入记录时,当我添加 CHR(10) + CHR(13) 时,我需要将换行符嵌入到字段中到 .txt 文件中,它会将实际换行放入导入记录中,而不是嵌入。

您可以给我任何语法示例:

** 这个示例不起作用!我可以获得如何正确嵌入这些换行符的示例吗? 萨姆·詹金斯 + CHR(13) + CHR(10) + Address1 + CHR(13) + CHR(10) + Address2

谢谢 - 埃文

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 these line feeds correctly?
Sam Jenkins + CHR(13) + CHR(10) + Address1 + CHR(13) + CHR(10) + Address2

Thanks - Evan

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一萌ing 2024-10-22 05:26:48

也许我不明白操作问题,但是....

ASCII 编码:

CHR(10) = 换行符/换行符

CHR(13) = 回车符

大多数文本文件查看器会将光标向下移动一行并移至左边距他们遇到了 CHR(13)CHR(10)。您的文件可能是正确的,只是您用来查看它的任何内容都尊重字符。如果文本被引号括起来并且查看者尊重这一点,您可能会得到您想要的显示,否则查看者将不知道何时嵌入 CrLf 或真正的行尾。

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.

暮光沉寂 2024-10-22 05:26:48

抱歉,您无法以其他方式绕过表示换行+回车的文本文件。我建议采取某种解决方法。也许你可以像 C 那样对它们进行编码,“\n”在 VFP 和文本文件中可以正常工作。不过,您必须在使用应用程序中对其进行解码。

你的具体例子看起来很奇怪。如果我正在编写一个逗号分隔的文件,我会用逗号“Name, Addr1, Addr2”而不是 lfcr 分隔字段。然后,VFP 将通过简单的附加从 x 类型 csv 导入该数据。

如果您尝试从字段分隔到不同行的文件中读取数据,则您将需要做更多的工作。如果幸运的话,文件始终使用相同数量的字段,您只需计算行号即可知道您所在的字段。 (第 1 行是名称,第 2 行是 addr1,第 3 行 addr2,第 4 行城市州邮政编码,第 5 行下一个名称...)如果是这种情况,我会使用循环和一些局部变量,然后将它们收集到空白表行。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文