Re: Assigning Variables at runtime?



Damfino wrote:
The text file would then look something like this:
Var1 1 Bit
Var2 16 Bits
Var3 3 Bits
etc.

My application can then use this definition to interpret the data block
and allow  for manipulation, etc.

Anyone has an idea if this is even possible?

Of course thats possible.

What you can't do is something like "create a record type fitting the
type specified in the textfile, then read that record at once".

What you of course CAN do, is something like defining 3 arrays:

VarName:array[0..maxfieldnum] of string;
VarLength:array[0..maxfieldnum] of integer;
VarValue:array[0..maxfieldnum] of integer; // for any var size from 1 to 31 bits


fill it from the text file, write yourself a routine like

function ReadVar(NumberOfBits:integer):integer;

that will read the bits one by one and merge them to
an int.


.



Relevant Pages