FoxPro "команда содержит нераспознанную фразу ключевое слово" ошибка времени выполнения - PullRequest
0 голосов
/ 24 января 2012

I m new to foxpro and it s рабочие области - это то, что я не получаю t really don, поэтому вполне вероятно, в чем проблема.

В основном у меня есть форма, которая берет 2 файла .csv и помещает их вfoxpro tables.

Я получаю сообщение об ошибке во время выполнения в последней строке этого сообщения. Может ли кто-нибудь увидеть проблему?

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

Кроме того, я не автор оригинала, я специалист по обслуживанию.так что если все выглядит странно, потому что я использовал его код, не понимая его.

1 Ответ

3 голосов
/ 25 января 2012

Да, похоже на очень старый код, но позвольте мне попытаться помочь вам понять, что происходит ...

    */ 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

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...