AnsweredAssumed Answered

Importing a Text file to create a Record

Question asked by stiv3n2000 on Dec 2, 2009
Latest reply on Dec 7, 2009 by PingWei
Hi Forum,

I've just started using Vee and this is my first post on the Forum.
I'm looking for advice as to how I can import a text file and create a Record from the read data.

The file is ultimately a database containing "sets" of configuration information representing multiple data types (String's, Int's, Float's) which I'm trying to parse into a Record.
One of the problems is that these 'sets' are NOT all the same size.  Their lengths alter (see below) due to the optional NextFieldData.

uInt    TestNumber......................  ->         Single byte
String TestName......................  ->         up to 32 Chars in length
enum  NextField_TypeDescriptor....   ->         where the Types are :  0= No NextFieldData,  1= Char[32] ,  2=Float,   3=Int  
union  NextFieldData1................   ->         ie NextFieldData can either be :  'NotPresent' or any number of bytes up to 32
enum  NextField_TypeDescriptor
union  NextFieldData2
enum  NextField_TypeDescriptor
union  NextFieldData3

So each member 'set' can have a length of anything between 36 bytes (ie no NextFieldData) to 132 bytes (ie all NextFieldData present)

So what I trying to do is feed a serial input of data from a file and break it up into the appropriate Fields for the record. 
I was trying to use a 'From->File' to read in the data. After numerous attempts I convinced myself that due to the varying length I would need to read it in 'byte-by-byte' so I could parse the NextField_TypeDescriptor to determine what kind of data Field to assign the next bytes (if any) to.

Any help or pointers to examples would be greatly appreciated.

Thanks. (your still struggling to think 'Vee' not 'C')