Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Importing data stored in native 'c' format
Message
General information
Forum:
Visual FoxPro
Category:
FoxPro 2.x
Miscellaneous
Thread ID:
00099006
Message ID:
00099087
Views:
22
Michael,

You'll have to use fopen() and fread( , 24 ) to read each record. Unit8 should map to a number 0-255, Uint32 should map to VFP integer. time_t is an VFP integer and it's seconds since midnight Jan 1, 1970. You can convert that to a datetime by adding it to {1/1/1970 00:00:00} the float will have to be bit and byte converted. I've never written that conversion but your C++ guy should be able to tell you how the sign, mantissa ans exponent are stored.

These routines will help with the UInt32 and time_t fields. You use FromLong() to convert them to VFP values.

* ConvertAPI.prg 08-Oct-97

* these functions convert to/from internal binary storage

function ToWord( pnNumber )
nMSB = int( pnNumber / 256 ) && most significant byte
nLSB = pnNumber % 256 && least significant byte
return chr( nLSB ) + chr( nMSB )

function ToLong( pnNumber )
nMSW = int( pnNumber / 65536 ) && most significant word
nLSW = pnNumber % 65536 && least significant word
return ToWord( nLSW ) + ToWord( nMSW )

function FromWord( pcBuffer )
return asc( substr( pcBuffer, 2, 1 ) ) * 256 + asc( left( pcBuffer, 1 ) )

function FromLong( pcBuffer )
return FromWord( substr( pcBuffer, 3, 2 ) ) * 65536 + FromWord( left( pcBuffer, 2 ) )


>I have a need to import data generated from a machine controled by a C++ application. This application creates a data file in the format of:

>typedef struct {
>    char name[10];
>    UInt8 tests;
>    Uint32 Sample;
>    time_t timeoftest;
>    float value;
>    } T_Series

>My FoxPro application is curently in FoxPro 2.6a, but I also have FoxPro 3.0a & 5.0. Any help would be appreciated.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Reply
Map
View

Click here to load this message in the networking platform