Navigation:  JetServer Editor >

JetServer Editor Source code generation

Previous pageReturn to chapter overviewNext page

The most important part of the server editor is of course the source code it generates.

We have chosen for a template based solution, just like the DbServer editor. The template file is named VO2JETED.TPL.

We have used the sampe template tokens, such as %classname%, that were used in the DbServer editor.

 

This template contains the following sections:

 

CLASS

This section contains the source code that will be geerated for every server. The generated code will be finished with a comment line that looks like:

//USER CODE STARTS HERE (do NOT remove this line)

 

INIT

This section contains the sourcecode for the init method of the server.

 

FIELDDESC

This section contains the sourcecode for the FieldDesc access

 

PREINIT

This section contains the sourcecode for the (optional) Preinit method

 

POSTINIT

This section contains the sourcecode for the (optional) Postinit method

 

FSCLASS

Normally when generating fieldspecs the code template in CAVOFED.TPL will be used. If you select 'Small Fieldspecs' the Jet Server editor will use its own template file, and use this section for the class declaration of the fieldspecs

 

FSINIT

Normally when generating fieldspecs the code template in CAVOFED.TPL will be used. If you select 'Small Fieldspecs' the Jet Server editor will use its own template file, and use this section for the init method of the fieldspecs

 

 

A sample of the generated code looks like this

Dynamic hyperlabels        Yes

Small fieldspecs        Yes

No Accesses/assigns        No

 

CLASS tblShippers INHERIT DaoQuery

//USER CODE STARTS HERE (do NOT remove this line)

 

METHOD INIT(cTablename, nRecSetType, nOptions, oDB ) CLASS tblShippers

   LOCAL i,nFields   AS INT

   LOCAL aFieldDesc  AS ARRAY

   LOCAL nPos        AS INT

 

   IF IsNil(cTablename)

         cTablename := "Shippers"

   ENDIF

   IF IsNil(nRecSetType)

         nRecSetType := dbOpenDynaset

   ENDIF

   IF IsNil(nOptions)

         nOptions    := NIL

   ENDIF

   IF IsNil(oDb)

       oDb := DaoCurrentDb()

       // The database in the JetServer Editor was: C:\VO2Jet\northwind.mdb

   ENDIF

 

   SELF:PreInit()

 

   SELF:UsePropsForHl := .T.

 

   SUPER:INIT(cTablename, nRecSetType, nOptions, oDB )

 

   IF .NOT. .T.

 

         oHyperLabel := HyperLabel{#tblShippers, "", "", ""}

   ENDIF

 

   IF oHLStatus = NIL

       nFields := ALen(aFieldDesc := SELF:FieldDesc)

       FOR i:=1 UPTO nFields

           nPos := SELF:FieldPos( aFieldDesc[i][DBC_NAME] )

 

           SELF:SetDataField( nPos,;

               DataField{aFieldDesc[i][DBC_SYMBOL],aFieldDesc[i][DBC_FIELDSPEC]} )

       NEXT

 

       SELF:GoTop()

   ENDIF

 

   SELF:PostInit()

 

   RETURN SELF

 

ACCESS FieldDesc CLASS tblShippers

   //

   //  Describes all fields selected by DBServer-Editor

   //

   LOCAL aRet      AS ARRAY

   LOCAL nFields   AS INT

 

   nFields := 3

 

   IF nFields > 0

       aRet := ArrayCreate(nFields)

 

       //

       //  The following code creates an array of field

       //  descriptors with these items for each

       //  selected field:

       //

       //  { <symFieldName>, <cFieldName>, <oFieldSpec> }

       //

       //  Use following predefined constants to access

       //  each subarray:

       //

       //  DBC_SYMBOL

       //  DBC_NAME

       //  DBC_FIELDSPEC

       //

       aRet[1]        := {#ShipperID, 'ShipperID', tblShippers_ShipperID{} }

       aRet[2]        := {#CompanyName, 'CompanyName', tblShippers_CompanyName{} }

       aRet[3]        := {#Phone, 'Phone', tblShippers_Phone{} }

         

 

   ELSE

       aRet := {}

   ENDIF

 

 

   RETURN aRet

 

ACCESS ShipperID CLASS tblShippers

Return Self:FieldGet(#ShipperID)

 

ASSIGN ShipperID(uValue) CLASS tblShippers

Return Self:FieldPut(#ShipperID,uValue)

 

CLASS tblShippers_ShipperID INHERIT FIELDSPEC

METHOD INIT() CLASS tblShippers_ShipperID

   LOCAL cPict        AS STRING

   SUPER:INIT(#ShipperID, "N", 11, 0)

   cPict := ""

   IF sLen(cPict) > 0

         SELF:Picture := cPict

   ENDIF

   RETURN SELF

 

ACCESS CompanyName CLASS tblShippers

Return Self:FieldGet(#CompanyName)

 

ASSIGN CompanyName(uValue) CLASS tblShippers

Return Self:FieldPut(#CompanyName,uValue)

 

CLASS tblShippers_CompanyName INHERIT FIELDSPEC

 

METHOD INIT() CLASS tblShippers_CompanyName

   LOCAL cPict        AS STRING

   SUPER:INIT(#CompanyName, "C", 40, 0)

   cPict := ""

   IF sLen(cPict) > 0

         SELF:Picture := cPict

   ENDIF

   RETURN SELF

 

ACCESS Phone CLASS tblShippers

Return Self:FieldGet(#Phone)

 

ASSIGN Phone(uValue) CLASS tblShippers

Return Self:FieldPut(#Phone,uValue)

 

CLASS tblShippers_Phone INHERIT FIELDSPEC

METHOD INIT() CLASS tblShippers_Phone

   LOCAL cPict        AS STRING

   SUPER:INIT(#Phone, "C", 24, 0)

   cPict := ""

   IF sLen(cPict) > 0

         SELF:Picture := cPict

   ENDIF

   RETURN SELF