FoxPro“命令包含无法识别的短语关键字”运行时错误

发布于 2024-12-28 20:07:47 字数 1045 浏览 0 评论 0原文

是 Foxpro 的新手,它的工作区域是我不太了解的东西,所以这可能就是问题所在。

基本上我有一个表单,需要 2 个 .csv 文件并将它们放入 FoxPro 表中。

我在最后一行遇到运行时错误,任何人都可以看到问题吗?

web_file    = Thisform.mcFile
web_file2   = thisform.mcfile2
web_letter  = Thisform.mcLetter
web_gl      = Thisform.mcGl
web_gl2     = Thisform.mcGl2
Set Date To Dmy

Close Data

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

mcFile  = Thisform.mcFile
mcFile2 = Thisform.mcFile2

Wait Clear

If File("web_temp.dbf")
    Delete File web_temp.Dbf
Endif
Create Table web_temp (;
    email1          C(40),;
    opentime1       C(40),;
    o2idnumb1       C(10))

Use
Select 0
USE web_temp Exclusive
Append From &web_file Delim

If File("web_temp2.dbf")
    Delete File web_temp2.Dbf
Endif
Create Table web_temp2 (;
    email           C(40),;
    opentime        C(40),;
    o2idnumb        C(10))  

Use
Select 0
USE web_temp2 Exclusive

APPEND FROM &web_file2 Delim

另外,我不是原作者,我是维护人员。所以如果事情看起来很奇怪,那是因为我一直在使用他的代码而没有真正理解它。

Im new to foxpro and its work areas are something i dont really dont get so that`s likely where the problem is.

Basically i have a form that takes 2 .csv files and puts them into foxpro tables.

I get a run time error at the last line of this, can anyone see the problem?

web_file    = Thisform.mcFile
web_file2   = thisform.mcfile2
web_letter  = Thisform.mcLetter
web_gl      = Thisform.mcGl
web_gl2     = Thisform.mcGl2
Set Date To Dmy

Close Data

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

mcFile  = Thisform.mcFile
mcFile2 = Thisform.mcFile2

Wait Clear

If File("web_temp.dbf")
    Delete File web_temp.Dbf
Endif
Create Table web_temp (;
    email1          C(40),;
    opentime1       C(40),;
    o2idnumb1       C(10))

Use
Select 0
USE web_temp Exclusive
Append From &web_file Delim

If File("web_temp2.dbf")
    Delete File web_temp2.Dbf
Endif
Create Table web_temp2 (;
    email           C(40),;
    opentime        C(40),;
    o2idnumb        C(10))  

Use
Select 0
USE web_temp2 Exclusive

APPEND FROM &web_file2 Delim

Also, im not the original author, im the maintenance guy. so if things look weird its because ive been using his code without really understanding it.

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

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

发布评论

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

评论(1

臻嫒无言 2025-01-04 20:07:47

是的,看起来像是非常古老的代码,但让我尝试帮助您了解正在发生的事情...

    */ create local memory variables (web_file, web_file2, etc) from properties
    */ that exist on the form (Thisform.mcFile, Thisform.mcFile2)  No problems here
        web_file    = Thisform.mcFile
        web_file2   = thisform.mcfile2
        web_letter  = Thisform.mcLetter
        web_gl      = Thisform.mcGl
        web_gl2     = Thisform.mcGl2

*/ If doing an import of data that is "Date" based, Foxpro will expect it in
*/ Day Month Year format, but you don't appear to be doing anything with it 
*/ during your import of CSV file
        Set Date To Dmy

*/    Close database(s) that may be open
        Close Data

        * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

*/ Does the exact same as above with "web_file" and "web_file2", 
*/ so you now have two variables each with exact same values...
        mcFile  = Thisform.mcFile
        mcFile2 = Thisform.mcFile2

*/    clear the "wait" window
        Wait Clear


*/ Look to see if there is an old version of "Web_Temp.dbf", if so, 
*/ delete it and recreate it with the provided "create table" structure. 
        If File("web_temp.dbf")
            Delete File web_temp.Dbf
        Endif
        Create Table web_temp (;
            email1          C(40),;
            opentime1       C(40),;
            o2idnumb1       C(10))

*/ These three lines are not needed.  When you "CREATE TABLE", you are 
*/ explicitly STARTING the file in exclusive mode, no need to close 
*/ and re-open exclusively.
        Use
        Select 0
        USE web_temp Exclusive


*/ Take the content from the file by the name found in the variable "web_file".  
*/ This could cause a problem if the file has embedded spaces in the name... 
*/ the preferred method is to use ( parens ).  The expectation of "Delim" is 
*/ that the file is comma delimited between each expected column name
        && Append From &web_file Delim
        Append from (web_file) Delim

*/ Do the same here, but for the second file going into a second 
*/ "Temp" table for processing 
        If File("web_temp2.dbf")
            Delete File web_temp2.Dbf
        Endif
        Create Table web_temp2 (;
            email           C(40),;
            opentime        C(40),;
            o2idnumb        C(10))  

*/    Again, dont need this
        Use
        Select 0
        USE web_temp2 Exclusive

        && APPEND FROM &web_file2 Delim
        append from (web_file2) Delim

现在,总而言之,这里有一些超级快捷方式供您使用,特别是如果这些实际上是临时表,否则您将是“完成后丢弃”...

*/ 上面的内容并没有确认预期的文件是否存在,所以我会预先检查

if not file( Thisform.mcFile )
   messagebox( "Sorry, the file " + Thisform.mcFile + " does not exist" )
   return
endif 

if not file( Thisform.mcFile2 )
   messagebox( "Sorry, the file " + Thisform.mcFile2 + " does not exist" )
   return
endif 

*/ In case a cursor/table is already open by the name "Web_Temp", close it
use in select( "Web_Temp" )
*/ Create a new table (temporary table that automatically 
*/ erases itself when closed when you are finished with it
create cursor Web_Temp (;
        email1          C(40),;
        opentime1       C(40),;
        o2idnumb1       C(10))

*/ Append from the file as before
append from ( Thisform.mcFile ) delim

*/ Go to another "work area" VFP allows up to 65535 different work areas, but if you
*/ ever needed that many tables open simultaneously, you have bigger problems.
select 0

*/ Same here, but for your SECOND table
use in select( "Web_Temp2" )
Create cursor web_temp2 (;
        email           C(40),;
        opentime        C(40),;
        o2idnumb        C(10))  

*/ Append from the file as before
append from ( Thisform.mcFile2 ) delim

*/ Done, continue with rest

如果您有一个十六进制值的文件,它们将被逐字拉入,如图所示在记事本编辑器中。 (或通过 MODIFY COMMAND NameOfTheFile)从 VFP 中

Yup, looks like very old code but let me try to help you understand what is going on...

    */ create local memory variables (web_file, web_file2, etc) from properties
    */ that exist on the form (Thisform.mcFile, Thisform.mcFile2)  No problems here
        web_file    = Thisform.mcFile
        web_file2   = thisform.mcfile2
        web_letter  = Thisform.mcLetter
        web_gl      = Thisform.mcGl
        web_gl2     = Thisform.mcGl2

*/ If doing an import of data that is "Date" based, Foxpro will expect it in
*/ Day Month Year format, but you don't appear to be doing anything with it 
*/ during your import of CSV file
        Set Date To Dmy

*/    Close database(s) that may be open
        Close Data

        * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

*/ Does the exact same as above with "web_file" and "web_file2", 
*/ so you now have two variables each with exact same values...
        mcFile  = Thisform.mcFile
        mcFile2 = Thisform.mcFile2

*/    clear the "wait" window
        Wait Clear


*/ Look to see if there is an old version of "Web_Temp.dbf", if so, 
*/ delete it and recreate it with the provided "create table" structure. 
        If File("web_temp.dbf")
            Delete File web_temp.Dbf
        Endif
        Create Table web_temp (;
            email1          C(40),;
            opentime1       C(40),;
            o2idnumb1       C(10))

*/ These three lines are not needed.  When you "CREATE TABLE", you are 
*/ explicitly STARTING the file in exclusive mode, no need to close 
*/ and re-open exclusively.
        Use
        Select 0
        USE web_temp Exclusive


*/ Take the content from the file by the name found in the variable "web_file".  
*/ This could cause a problem if the file has embedded spaces in the name... 
*/ the preferred method is to use ( parens ).  The expectation of "Delim" is 
*/ that the file is comma delimited between each expected column name
        && Append From &web_file Delim
        Append from (web_file) Delim

*/ Do the same here, but for the second file going into a second 
*/ "Temp" table for processing 
        If File("web_temp2.dbf")
            Delete File web_temp2.Dbf
        Endif
        Create Table web_temp2 (;
            email           C(40),;
            opentime        C(40),;
            o2idnumb        C(10))  

*/    Again, dont need this
        Use
        Select 0
        USE web_temp2 Exclusive

        && APPEND FROM &web_file2 Delim
        append from (web_file2) Delim

Now, all that said, here is some super shortcuts for you, especially if these are in fact temporary tables that you would otherwise be "discarding" when finished...

*/ The above doesn't confirm expected files exist, so I would pre-check

if not file( Thisform.mcFile )
   messagebox( "Sorry, the file " + Thisform.mcFile + " does not exist" )
   return
endif 

if not file( Thisform.mcFile2 )
   messagebox( "Sorry, the file " + Thisform.mcFile2 + " does not exist" )
   return
endif 

*/ In case a cursor/table is already open by the name "Web_Temp", close it
use in select( "Web_Temp" )
*/ Create a new table (temporary table that automatically 
*/ erases itself when closed when you are finished with it
create cursor Web_Temp (;
        email1          C(40),;
        opentime1       C(40),;
        o2idnumb1       C(10))

*/ Append from the file as before
append from ( Thisform.mcFile ) delim

*/ Go to another "work area" VFP allows up to 65535 different work areas, but if you
*/ ever needed that many tables open simultaneously, you have bigger problems.
select 0

*/ Same here, but for your SECOND table
use in select( "Web_Temp2" )
Create cursor web_temp2 (;
        email           C(40),;
        opentime        C(40),;
        o2idnumb        C(10))  

*/ Append from the file as before
append from ( Thisform.mcFile2 ) delim

*/ Done, continue with rest

If you have a file that is underlying as hex values, they'll just be pulled-in verbatim as would be seen in a notepad editor. (or via MODIFY COMMAND NameOfTheFile) from within VFP

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