|
Home > Archive > Getting Started with dBASE > January 2006 > Error with Calculated Field
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Error with Calculated Field
|
|
| Forrest Ganther 2006-01-29, 3:23 am |
| I am trying to set up a "Calculated Field" and set up a
Datamodule almost identical to the Customer.dmd
in the Tutorial.
Everything seems to go fine until I add the
FullName_beforeGetVa
lue code. The blank fullName field is visible in
dQuery's lower pane.
But when I add the beforeGetValue code, I get the following error.
CLASS does not exist
MemberDatamodule::Fu
llName_Before...
File qComponents.cc
Routine QRowComponent :: FieldList _ onGotFocus
I have redid and re-checked until I'm blue in the face! What have I missed?
Thanks for any help
Forrest
| |
| Jean-Pierre Martel 2006-01-29, 3:23 am |
| In article <JPLv00HJGHA.1100@news-server>, forrestganther@sbcgl
obal.net
says...
>
> Everything seems to go fine until I add the
> FullName_beforeGetVa
lue code.
Under the Source code editor, the code of your DMD should have the
following skeleton when you create a calculated field:
** END HEADER -- do not remove this line
//
// Generated on 04/11/01
//
class CustomerDATAMODULE of DATAMODULE
...
this.MyTable1 = new QUERY()
this.MyTable1.parent = this
with (this.MyTable1)
onOpen = class::MyTable1_ONOP
EN
...
endwith
function MyTable1_onOpen
local oField1, oField2
// example A: a codeblock
oField1 = new field()
oField1.fieldName = 'cDate'
oField1.length := 30
this.rowset.fields.add(oField1)
oField1.beforeGetValue = ;
{|| " " + dtoj(this.parent["Date1"].value) }
// example B: a function
oField2 = new field()
oField2.length = 45
oField2.fieldName = 'FullName'
this.rowset.fields.add(oField2)
oField2.beforeGetValue = class::CREATE_FULLNA
ME
return
Function Create_FullName
return ( ;
this.parent["First_Name"].value ;
+ " " ;
+ this.parent["Last_Name"].value ;
)
endclass
Jean-Pierre Martel, editor
The dBASE Developers Bulletin
Blue Star dBASE Plus Core Concepts Graduate
| |
| Ronnie MacGregor 2006-01-29, 7:23 am |
| In article <JPLv00HJGHA.1100@news-server>, forrestganther@sbcgl
obal.net
says...
> I am trying to set up a "Calculated Field"
A good quick way to build calculated fields and to check that they
produce the expected results, is to use the Calculated Field Builder in
QR3 :
http://www.dbasedeveloper.co.uk/QR3/QR3.htm
Although the QR3 calculated field builder is designed for reports, the
code for a calculated field used anywhere is exactly the same, so you
can design and redesign your field in QR3, get an instant preview of the
results, and once you are happy, save the Report and then copy and paste
the relevant code from the generated report code to wherever you want.
Even if you are an expert calculated field hand coder, the above method
is faster than typing !
There is a support article on QR3 if you need it :
http://www.dbasedeveloper.co.uk/dBulletin/bu18qr3.htm
Hope this helps.
--
Ronnie MacGregor
Scotland
www.dBASEdeveloper.co.uk
| |
| Michael Nuwer [dBVIPS] 2006-01-29, 7:23 am |
| Forrest Ganther wrote:
> I am trying to set up a "Calculated Field" and set up a
> Datamodule almost identical to the Customer.dmd
> in the Tutorial.
>
> Everything seems to go fine until I add the
> FullName_beforeGetVa
lue code. The blank fullName field is visible in
> dQuery's lower pane.
>
> But when I add the beforeGetValue code, I get the following error.
Hello Forrest, This is a bug. One way to deal with it is to simple click
the "ignore" button in the error message box. You will get the error
message more than once; "ignore" in all cases.
Another possibility is to add the second following line:
class CustomerDATAMODULE of BaseCDATAMODULE from ...
set procedure to program(1) additive
The main problem here is that the dBASE streaming engine will remove
this line each time you save the file and you must therefore edit again
before opening.
You might alternatively try putting the "set procedure" line in the
query's canOpen event handler.
The bug manifest itself when a custom datamodule is used. Absent such a
custom object, the bug does not raise its head.
|
|
|
|
|