: Question 1
: How can you create a variable that can be changed from one data type to another during run time.Which data type would be better variant or a byte array
:
A byte array can hold all types, while a variant is automatically converted. So either type has its pros and cons. If memory is an issue, I would suggest a byte array, since that is somewhat smaller, but otherwise are variants shorter to code.
: Question 2
: I need help in converting the entire byte array into a specific data type .At the moment i can only know how to convert a specific byte into some value
:
You can use the Move() routine for that. Here is an example to copy a float into a byte array, and back again.
SetLength(ByteArray, SizeOf(myFloat));
Move(MyFloat, ByteArray, Length(ByteArray));
... { code using the ByteArray }
Move(ByteArray, MyFloat, Length(ByteArray));
Obviously this method has a huge inherent danger: you can easily type-cast the bytearray into a variable, which is too small. This might lead to loss of data.
: Question 3
: Are there any datatype variables in delphi that allow you to store a time calue without a date at the moment i can only find a data type TTimeField which i think is supposed to be used as a form component but i only want to store the time not display or store it on a form
:
There are no purely time types. You can always use a TDateTime typed variable, and just ignore the date part.