Calculated Field Problem. Delphi w/ Pdox 4.5 Table

Calculated Field Problem. Delphi w/ Pdox 4.5 Table

Post by Chris Milliki » Fri, 06 Dec 1996 04:00:00



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?)

Thanks in advance
Chris

 
 
 

Calculated Field Problem. Delphi w/ Pdox 4.5 Table

Post by Paul Schop » Fri, 06 Dec 1996 04:00:00



> 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?)

> Thanks in advance
> Chris

--
Paul Schopf

 
 
 

Calculated Field Problem. Delphi w/ Pdox 4.5 Table

Post by Chris Milliki » Fri, 06 Dec 1996 04:00:00


Thanks to Paul, I think I figured it out:

READYQUECalcDLT1.Value := Int(READYQUEDispatchlatesttime.Value);
READYQUECalcDLT2.Value := ((READYQUEDispatchlatesttime.Value -
Int(ReadyqueDispatchlatesttime.Value))*60);
READYQUECalcDLT.AsString := READYQUECalcDLT1.AsString +':'+
READYQUECalcDLT2.AsString;

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?)

> > Thanks in advance
> > Chris

> --
> Paul Schopf

 
 
 

Calculated Field Problem. Delphi w/ Pdox 4.5 Table

Post by Edhi Nugro » Sun, 08 Dec 1996 04:00:00



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


 
 
 

1. Exporting Pdox memo fields to ascii - Pdox for Win 4.5

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?

Thanx in advance.

Pete Farkas

BTW, please respond via email if at all possible.

2. Beryl, this is my view from NYC

3. calculated field using record num in report problem with 4.5 dos

4. How to get AutoNumber Datatype???

5. Pdox 4.5 dos table problems

6. Which database?

7. Pdox 3.5 vs.Pdox 4.02 vs. Pdox 4.5

8. Protect your money from PROBATE shark lawyers

9. Field changed, pdox 4.5(dos)

10. ((((HELP)))) Pdox 4.5, Export Memo Field

11. Calculated field in form, Paradox 4.5 dos

12. PDOX 4.5 Deleting blanks at end of field

13. PDOX 4.5 WIN - TableFrame Field Manipulation