Link to home
Start Free TrialLog in
Avatar of westy100697
westy100697

asked on

Help : Delphi 3.0 Floating Point Types

My Question is as follows......

 I am currently writing a program that will include a Database Structure Viewer as per Database DeskTop. Now I am
able to get all the fields pertaining to a particular table and also their sizes. ALL except the floating point numbers which
do not return anything in their size property. I need some way of reading their size ie their width and number of decimal places. I am sure this will be easy but I have just hit a brick wall and cannot seem to come up with a solution. This is to be used as a utility in a much larger program if the users happen to have database problems down the track.  Anyway
if you can help then you will get the points.

Thanks in Advance,
WESTY
Avatar of JimBob091197
JimBob091197

Hi

My help file for TField's Size property says "The interpretation of Size depends on the data type." and in particular for fields of type tfFloat "Size is not used; its value is always 0."

Regards,
JB
Hi again

There is also the DataSize property for fields.  Again, the help file has the following to say:
"For float fields, DataSize is always 8. Database tables store float fields as a Double, which is the same as the type used by TFloatField."

Cheers,
JB
Avatar of westy100697

ASKER

JimBob,
            This much I already know. The problem seems to be to try and diplay the tables
Structure information in a stringgrid. I am unable to ascertain for example if a TFloatfield that I have set through the Database Desktop has for example the following settings...

Field Name     Type      Size      Decimals

MYFIELD         F            6              3

This is the sort of info I require as if I do updates of the Tables for clients and I forget to send them the updated tables then I want to be able to get them to change the structure
while in the program. Otherwise I will get messages like "field 'MYFIELD' not of expected type"  . This will occur if I have for example changed the size of the field or the number of decimal places and this is what I want to be able to cover for. I hope this might shed some
more light on what I am trying to do.

PS.  As you stated earlier DataSize always displays 8 and so is useless to me as I need to be able to pin point the problem field.

Regards,

WESTY
Hi

I don't think you can get any more info for float fields.
TFloatField.Size = 0 (Always!!)
TFloatField.DataSize = 8

However, there is also a numeric field type called TBCDField.
TBCDField.Size = Number of digits AFTER decimal point.
TBCDField.DataSize = 34

In your example you say MyField is of type F.  Type F is type "Formatted Memo."  What version of Delphi & Database Desktop are you using?  I'm using DB Desktop 7 with Paradox 7, and Delphi 3.

JB
JimBob,
            I am using dBase tables and so F is a Float Field not a Memo. But yeh I thought as much with regards to a Float Field which is why I am impressed with DB Desktop as it is able to display the field structures with the correct field size and decimal places. I would have put money on that there was a work around but it seems I have come up with a blank. I am also using Delphi 3 and DB Desktop 7 . I have exhausted the help but there is nothing really specific to my problem. The same in Books I have purchased relating to Delphi 3. Surely if DB Desktop can do it then it must be able to be done. Very frustrating.
Anyway I hope someone may know the answer to the problem and so I am going to bump
the points up a little more as it seems to be a goodun.

Cheers
WESTY
Hi Westy

The DB Desktop must be using the BDE API.  This file is bde.int, and can be found in Delphi\Doc directory.

DB Desktop probably uses the call DbiGetFieldDescs, which returns a FLDDesc structure.  I think your info may be in the iUnits1 or iUnits2 part of the FLDDesc.

I will play around with DbiGetFieldDescs, and if I come up with anything I will let you know.

Cheers,
JB
JimBob,
            Yeh I was going to say before that I have already had a look in the old dbiprocs.int
file from delphi 1 to see if that could shed any light on it but drew a blank also. But your suggestion about the bde.int file sounds very interesting and I will look at it also to see if I can resolve anything. Looks like I may be closer after all.

Thanks.
WESTY
Yes. JB is right, the iUnits2 showsthe number of digits after the point. I allready have  a source code. If JB won't find the solution for you, I'll post it later.

Ronit
Ronit,
         Yeh no worries, I have had a decent look at the bde.int file and have been able to implement the code in my app. but it will just take a little mucking around to get it working
error free. But if you already have source code written to do a similar thing post it if JimBob hasn't been able to find a solution. Will be happy to award points to both.

WESTY
OK, let me know when you want it to be posted.
Hey this is WESTY here. I have had a bit of trouble trying to LOG ON with westy so I have set up another registered name boabyte. Now with regards to the problems I have listed above I have solved it thanks to JimBob and pointing me towards the bde.int file. Thanks
JimBob I have it working well now in my APP and have only got to write changes to a table now but the hard part is done. If you lock the question (JimBob) I will award you the points. Thanks very much.

Regards
WESTY
ASKER CERTIFIED SOLUTION
Avatar of JimBob091197
JimBob091197

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial