Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ONE FOR THE EXPERTS - Appending lines with different for
Message
 
À
12/05/1998 09:20:22
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00098397
Message ID:
00098757
Vues:
67
You could open the INCOMING.SDF file with the low-level function (FOPEN) and walk through it line by line. Check the first character of the line and INSERT it into the correct table. It would look something like this:

lnHandle = FOpen('INCOMING.SDF') && Open the file
If lnHandle = -1 && File did not open properly
MessageBox('Uh-Oh')
Return && Go make sure the File is open somewhere else and try again
EndIf && The file is open so you can continue
Do While !FEOF(lnHandle) && Loop through the entire file
lcRecord = FGets(lnHandle) && Store one line of the file into lcRecord
Do Case
Case Left(lcRecord,1) = 'A' && A means this record goes into table1
Insert Into Table1 Values SubStr(lcRecord,2) && Ecludes the first char
Case Left(lcRecord,1) = 'B' && B means this record goes into table2
Insert Into Table2 Values SubStr(lcRecord,2)
... && Do this for each record type
...
EndCase
EndDo
FClose(lnHandle)

HTH


>>Howdy from Nashville!
>>
>>Forgive me if this is a "newbie" question, but...
>>
>>I have an SDF file that I must append into a set of tables. Every line in the file can have a different layout and length depending on what kind of record it is. The kind of record is determined by the first character of the line.
>>
>>Here is the basic situation:
>>
>>INCOMING.SDF can have different layouts on a line by line basis, so I need to be able to look at the first character of an entire line, then append the entire line into a set of tables, like so:
>>
>>Line Layout 1 --> Table1.dbf (which just holds Layout 1 records)
>>Line Layout 2 --> Table2.dbf (etc.)
>>Line Layout 3 --> Table3.dbf
>>Line Layout 4 --> Table4.dbf
>>Line Layout 5 --> Table5.dbf
>>Line Layout 6 --> Table6.dbf
>>
>>I thought about appending the entire file, line by line, into 1 MEMO field (since these lines have over 254 character lengths) in a temporary database,
>
>Suppose all tableX.dbf have a C1 c(1) field as the first field, you could simply
>
>use table1
>append from incoming.sdf type sdf for c1="A"
>use table2
>append from incoming.sdf type sdf for c1="B"
>
>...etc. Unless you have to do this often (whereas this should be in a .prg), you can issue this in the command window.
_________________________________
There are 2 types of people in the world:
    Those who need closure
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform