Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
COPY SDF to the memory variable
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00537356
Message ID:
00537611
Vues:
21
It's not actually a SDF because there are no returns between the fields.
If you want CR+LF in the result you have to use the do while not feof() approach


>if it is a table, not a cursor, and the table is not too large, you could use the low level functions and read the data in one chunk. the dbf structure is a SDF file with a header that describes the structure of the data. there is a header() function that tells you the size of the header area and a fsize() cunction that gives you the size of the entire file. fsize()-header() = the data area.
>once you know the above you can:
>
>local lnHandle, nSizeOfFile, nSizeOfHeader, nSizeOfData
>USE MyFile
>nSizeOfHeader = HEADER()
>USE
>SET COMPATIBLE ON && use to get file size
>nSizeOfFile = FSIZE('MyFile.dbf')
>SET COMPATIBLE OFF
>nSizeOfData = nSizeOfFile - nSizeOfHeader
>lnHandle=fopen('MyFile.dbf')
>*nSizeOfFile = FSEEK(lnHandle,0,2) && another way to get the file size
>*nSizeOfData = nSizeOfFile - nSizeOfHeader
>=fseek(lnHandle, nSizeOfHeader)
>nDbfData = fread(lnHandle, nSizeOfData)
>=fclose(lnHandle)
>set cons on
>
>>>>>How can I get the same result as
COPY SDF TO Myfile.txt
>>>>>lcStr = Filetostr(Myfile.txt)
w/o writing to file and reading back.
>>>>
>>>>You can use low-level functions, but it would be more commands, than these two. On the other hand, you would not create a temp file...
>>>
>>>Can you explain?
>>pseudo-code (from the top of my head)
>>
>>local lnHandle
>>lnHandle=fopen('MyTable')
>>do while not feof(m.lnHandle)
>>   lcStr=m.lcStr+fread()...
>>enddo
>>
>>Anyway, this would not work in case of cursor. SELECT SQL probably would not work either, since it doesn't create SDF file...
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform