Calculated Field Problem. Delphi w/ Pdox 4.5 Table

Calculated Field Problem. Delphi w/ Pdox 4.5 Table

Gentle Folk,
I'm writing an application that is intended to upgrade an old Paradox
for DOS PAL application.  I'm trying to get Delphi to calculate a field
to display it in the proper format.  The field is a number like:
8.25
And represents the time 8:15
I've added the field in the fields editor, as a calculated field and
added this code to the OnCalc event:

Table1Field1.Value := Int(Table1Field1.Value) +':'+ (Table1Field1.Value
- Int(Table1Field1.Value))*60;

And I get a incompatible type error.  I've tried Trunc in place of Int
with limited success, but still have type problems.

Can someone shed some light on this for a newbie?  What are types?  Am I
trying to be too direct? (i.e. lazy?)

Chris

Calculated Field Problem. Delphi w/ Pdox 4.5 Table

> Gentle Folk,
> I'm writing an application that is intended to upgrade an old Paradox
> for DOS PAL application.  I'm trying to get Delphi to calculate a field
> to display it in the proper format.  The field is a number like:
> 8.25
> And represents the time 8:15
> I've added the field in the fields editor, as a calculated field and
> added this code to the OnCalc event:

> Table1Field1.Value := Int(Table1Field1.Value) +':'+ (Table1Field1.Value

^              ^                       ^              ^
is this String? Float?   This is integer     this is string    float?

Quote:> - Int(Table1Field1.Value))*60;

^                  ^
integer            integer

You are relying on implicit typecasts:

string := integer + string + ( float - integer ) * integer;

In pascal you have to be explicit about these things.

Look into asInteger, asFloat, asString, asTime, as well as Format, intToStr, etc.

Is your data stored as floating point? or as a string, like '4.25'

You must have it as a string if you are trying to change it from 4.25 to 4:15.

I am sorry that I am away from my PC now, but if you search for these in
the VCL help, you should find them (assuming 2.01 help files or the corrected
VCL help file)  Good luck!

Quote:

> And I get a incompatible type error.  I've tried Trunc in place of Int
> with limited success, but still have type problems.

> Can someone shed some light on this for a newbie?  What are types?  Am I
> trying to be too direct? (i.e. lazy?)

> Chris

--
Paul Schopf

Calculated Field Problem. Delphi w/ Pdox 4.5 Table

Thanks to Paul, I think I figured it out:

Put a Mask for Short Time on the field and viola!
Though times ending in 00 display like so:  "12:0" instead of "12:00".
But I'll figure that out.

> > Gentle Folk,
> > I'm writing an application that is intended to upgrade an old Paradox
> > for DOS PAL application.  I'm trying to get Delphi to calculate a field
> > to display it in the proper format.  The field is a number like:
> > 8.25
> > And represents the time 8:15
> > I've added the field in the fields editor, as a calculated field and
> > added this code to the OnCalc event:

> > Table1Field1.Value := Int(Table1Field1.Value) +':'+ (Table1Field1.Value
>            ^              ^                       ^              ^
>  is this String? Float?   This is integer     this is string    float?

> > - Int(Table1Field1.Value))*60;
>            ^                  ^
>          integer            integer

> You are relying on implicit typecasts:

>     string := integer + string + ( float - integer ) * integer;

> In pascal you have to be explicit about these things.

> Look into asInteger, asFloat, asString, asTime, as well as Format, intToStr, etc.

> Is your data stored as floating point? or as a string, like '4.25'

> You must have it as a string if you are trying to change it from 4.25 to 4:15.

>   I am sorry that I am away from my PC now, but if you search for these in
> the VCL help, you should find them (assuming 2.01 help files or the corrected
> VCL help file)  Good luck!

> > And I get a incompatible type error.  I've tried Trunc in place of Int
> > with limited success, but still have type problems.

> > Can someone shed some light on this for a newbie?  What are types?  Am I
> > trying to be too direct? (i.e. lazy?)

> > Chris

> --
> Paul Schopf

Calculated Field Problem. Delphi w/ Pdox 4.5 Table

writes:

Quote:>to display it in the proper format.  The field is a number like:
>8.25
>And represents the time 8:15
>I've added the field in the fields editor, as a calculated field and
>added this code to the OnCalc event:

>Table1Field1.Value := Int(Table1Field1.Value) +':'+ (Table1Field1.Value
>- Int(Table1Field1.Value))*60;

>And I get a incompatible type error.  I've tried Trunc in place of Int
>with limited success, but still have type problems.

Yes, you mixed string with Int.. that's why you got incompatible type
error. So, I think you should do :
1. Make the calculated field have a string type
2. Then change your OnCalc event handler as :

(assume that the 8.25 is in integer field called F1)
Table1['CalcField'] := IntToStr(int(Table1['F1']) +':'
+ IntToStr((Table1['F1'] -
int(Table1['F1'])*60)
HTH

I am exporting a pdox db that includes several memo fields to ASCII delimated
text. However, the  memo fields get truncated. I believe that the any info
included in the db file is exported, but not any included in an external memo
file. Is there any way to get pdox to export the entire field, external file
and all?