Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Appending from a textfile
Message
De
28/10/1999 18:55:57
 
 
À
28/10/1999 18:03:24
Jeffrey Score
Dept of Defense (Usmc)
Iwakuni, Japon
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00282827
Message ID:
00283485
Vues:
13
>Ed,
>
>I got the data to read into the table, but... When I do this it will read the first 158 characters (the report is 134 char per line) and then it will go to charecter 159 and start loading the second record in to the table. Do I need to set the fread to 268 so that it reads 2 full lines at a time and is there any way that I can filter the records that are read into the table?
>

You can either read 2 lines of 134 characters with two FREADs, or one of 268 characters. Since a VFP string variable can be any length, whatever is easier for you to figure out will work.

It sounds suspiciously like each line might be 132 characters long, terminated with a CHR(13) and a CHR(10) - in which case, you can use FGETS() to read a line at a time up to the CR/LF pair, and if any line is shorter than that, the FGETS() reads up to the length specified or the next end of line. You coudl also do something like:

CREATE CURSOR TempInput (OneRptLine C(132))
APPEND FROM name of input file TYPE SDF

You could now process the table TempInput, each record of TempInput containing representing one line of the input file. This would be equivalent to doing two FGETS() or two FREAD() operations of 134 characters; for your purposes, since you need to parse data coming from more than one input line at a time, the low-level FGETS() and APPEND...TYPE SDF approaches are roughly equivalent in how they'd work, and if you logically deal with blocks of 268 characters every time, a single FREAD() of 268 characters at a time might make more sense.

The file example I used had fixed length records of 97 characters each - there was no line terminator, so low-level I/O with FREAD() had to be used.

>I appreciate all of the help all of you give me out there. There is not much of a knowledge base here in Japan.
>
>Thanks and Semper Fi,
>
>Jeffrey Score
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform