Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Import data from text file
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01242133
Message ID:
01242186
Views:
21
>Nice Code Boris :)
>would you like to extend this eg.
>
>we can put some codes top of this code and to the bottom
>
>instead of getfile() first,
>we can create a cursor such as lselected L,filename c(50)
>and fill it .001 files after when user select some file(s)
>
>your codes will execute these files in a loop
>
>TIA


Sure, not tested and I didn't bother if some errors could happen:
lcCreate = [CREATE CURSOR crsImport (Fld1 C(20)]
FOR lnFor = 2 TO 19
    lcCreate  = lcCreate + [, Fld]+TRANSFORM(lnFor)+[ C(20)]
NEXT
lcCreate  = lcCreate + [)]
&lcCreate

lcDirForImport = GETDIR(,,,64)
IF NOT EMPTY(lcDirForImport)
   lnFiles = ADIR(laFiles,ADDBS(lcDirForImport)+[*.001])
   FOR lnFor = 1 TO lnFiles
       lcFileToImport = ADDBS(lcDirForImport)+laFiles[lnFor,1]
       SELECT crsImport
       APPEND FROM (lcFileToImport) DELIMITED
       RENAME (lcFileToImport) TO FORCEEXT(lcFileToImport,[TRN])
   NEXT 
ENDIF
SELECT crsImport
SCAN
     IF ALLTRIM(Fld1) == [01]
        *** Manage header record
        *** with proper transformation of the types
        *** between C(20) and the real Header table type
    ELSE
        *** Manage detail records
        *** with proper transformation of the types
        *** between C(20) and the real Detail table type
    ENDIF 
ENDSCAN
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform