Class definition advice needed. (SOLVED)

Class definition advice needed. (SOLVED)

Postby Horizon » Tue Dec 08, 2020 9:00 am

Dear Masters,

I have an browse class name TYK_List. I have an define line like above.

Code: Select all  Expand view  RUN
CLASS TYK_List FROM TYK_Core

    DATA oData
    DATA oDlg, oDlg_Other
    DATA oParent
    ....
    ....
    ....

    METHOD New( cVarName, cCerID, uData, aMyCols, aHeaders, cButtonPlace, SART, ARANAN, nOrd, aButtons, ;
            aRelations, aOptions, Esas_Isim, Ex_SART, aCargo, cSilKontrol, cOnBody, aArama, oData, ;
            lLineNo, cOnExtra_Caption, oApp, oFont_Brw, oFont_Edit, ldontExit, aStartUp, bOzelyetki, ;
            bOnLocked, cOnLocked, lDesc, lMultiSelect, oWnd, oParent, cPrefix_Sil, aKaydet_Kontrol, ;
            cTitle, cOnExtra_Bitmap, cIcon) CONSTRUCTOR
   
       
    METHOD GO_DETAY_Ekle()
    METHOD GO_DETAY()
    METHOD GO_SIL()
    METHOD GO_BUL()
    ....
    ....
    ....
   
    METHOD End()

ENDCLASS   
 


Code: Select all  Expand view  RUN
#xcommand DEFINE Ob_Browse1 <oOb_Brw> [OF <oWnd>];
                        [ CERCEVEID <cCerID> ] ;
                        [ UDATA <uData> ] ;
                        [ DATA <oData> ] ;
            [ <cols: COLS, COLUMNS> <aMyCols,...> ] ;
            [ <head:HEAD,HEADER,HEADERS> <aHeaders,...> ] ;
                        [ BUTTONYERI <cButtonPlace> ] ;
                        [ SART <cSART> ] ;
                        [ ARANAN <cARANAN> ] ;
                        [ ORDER <nOrd> ] ;
            [ <buttons:BUTTON, BUTTONS> <aButtons,...> ] ;
            [ <rela:RELATION, RELATIONS> <aRelations,...> ] ;
            [ <opt:OPTION, OPTIONS> <aOptions,...> ] ;
                        [ ESASISIM <cEsas_Isim> ] ;
                        [ EXTRASART <Ex_SART> ] ;
                        [ CARGO <uCargo> ] ;
                        [ ONSILKONTROL <cSilKontrol> ] ;
                        [ ONBODY <cOnBody> ] ;
            [ <aramavar: ARAMAVAR> <aAramaVar,...>] ;
            [ <lineno: LINENO> ] ;
                        [ EXTRABUTTON CAPTION <Ex_BCaption> ] ;
                        [ EXTRABUTTON BITMAP <Ex_BBitmap> ] ;
                        [ TITLE <cTitle> ] ;
                        [ APPLICATION <oApplication> ] ;
                        [ BROWSE FONT <oFont_Brw> ];
                        [ EDIT FONT <oFont_Edit> ];
                        [ PARENT <oParent> ] ;
            [ <ldontExit: DONTEXIT> ] ;
            [ STARTUP <aStartUp>] ;
            [ OZELYETKI <bOzelYetki>] ;
            [ ONLOCKED <bOnLocked>] ;
            [ ONLOCKED_VAR <cOnLocked>] ;
                        [ <lDesc: DESCENDING> ] ;              
                        [ <lMulti: MULTISELECT> ] ;            
                        [ PREFIX_SIL <cPrefix_Sil> ] ;
            [ <KONTROL> <aKontrols,...> ] ;
      => ;
          <oOb_Brw> := TYK_List():New(<(oOb_Brw)>, <cCerID>, <uData>, ;
                        [\{<aMyCols>\}],;
                        [\{<aHeaders>\}],;
                        [<cButtonPlace>],[<cSART>],[<cARANAN>],[<nOrd>],;
                        [<aButtons>],[\{<aRelations>\}],[<aOptions>],[<cEsas_Isim>],;
                        [<Ex_SART>],[<uCargo>],<cSilKontrol>,<cOnBody>,[<aAramaVar>], ;
                        <oData>, <.lineno.>, [<Ex_BCaption>], <oApplication>,;
                        [<oFont_Brw>], [<oFont_Edit>], <.ldontExit.>, <aStartUp>, <bOzelYetki>, ;
                        <bOnLocked>, <cOnLocked>, <.lDesc.>, <.lMulti.>, [<oWnd>], [<oParent>],;
                        [<cPrefix_Sil>], [\{<aKontrols>\}], [<cTitle>], [<Ex_BBitmap>] )
                   

This class has a dialog and can be define more than one same class in it. There is no problem. It works.

If there is an error in one dialog that called from first class, I could not found the which derived object is from.

I have decided to separate class like This

Code: Select all  Expand view  RUN
CLASS TMy_Purpose1 FROM TYK_List
ENDCLASS   

CLASS TMy_Purpose2 FROM TYK_List
ENDCLASS   

CLASS TMy_Purpose3 FROM TYK_List
ENDCLASS   

CLASS TMy_Purposen FROM TYK_List
ENDCLASS   


In this situation, I can not use define "Ob_Browse1" name. I should define every inherited class "TMy_Purpose?". But This class is constantly changing, it also defines.
I should not forget to change inherited class defines also.

Question :

Is there any general define method (or parameter) to run inherited classes from one define line?

Code: Select all  Expand view  RUN
xcommand DEFINE oMy_Purpose1        oOb_Browse1         // but should run TMy_Purpose1() instead TYK_List()
Last edited by Horizon on Tue Dec 08, 2020 6:10 pm, edited 1 time in total.
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: Class definition advice needed.

Postby nageswaragunupudi » Tue Dec 08, 2020 4:27 pm

Please try this sample and adapt to your requirements:
Code: Select all  Expand view  RUN
#include "fivewin.ch"

#xcommand DEFINE <o> Ob_Browse1  <n> [SUBCLASS <cClass>] => ;
   <o> := HB_ExecFromArray( IfNil( <cClass>, "TYK_LIST" ) ):New( <n> )

function Main()

   local o, o1, o2, O3

   DEFINE o  Ob_Browse1  1
   DEFINE o1 Ob_Browse1  1 SUBCLASS "TMY_PURPOSE1"
   DEFINE o2 Ob_Browse1  1 SUBCLASS "TMY_PURPOSE2"
   DEFINE o3 Ob_Browse1  1 SUBCLASS "TMy_Purpose3"

   ? o:ClassName(), o1:ClassName(), o2:ClassName(), o3:ClassName()

return nil

CLASS TYK_List
ENDCLASS

CLASS TMy_Purpose1 FROM TYK_List
ENDCLASS

CLASS TMy_Purpose2 FROM TYK_List
ENDCLASS

CLASS TMy_Purpose3 FROM TYK_List
ENDCLASS

CLASS TMy_Purposen FROM TYK_List
ENDCLASS


Image
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Class definition advice needed.

Postby Horizon » Tue Dec 08, 2020 6:05 pm

Thank you very much Mr. Rao,

This solved my problem.
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 93 guests