Application Prototyping/Generic Browse Routine

Source code related resources

Moderator: Rathinagiri

Post Reply
User avatar
dhaine_adp
Posts: 457
Joined: Wed Aug 06, 2008 12:22 pm
Location: Manila, Philippines

Application Prototyping/Generic Browse Routine

Post by dhaine_adp »

Greetings,

Here is a code snippet of my Generic Browse Class to browse a flat table like;
Products.DBF, ProductSize.DBF, etc for making input and as an initial form when a module was loaded by the user from Menu. The goal is to make a rapid application prototyping for presentation to customer/client and eventually use the same prototype for production or development of the application. Instead of making a separate module for each type of flat table you can call the routine by using something like this as an example:

BEGIN SEQUENCE
oTable := GenericBrwObj():New()
oTable:cWndTitle := "Collectors Master File"
oTable:cMainAlias := "COLLECTOR"
oTable:cMainFocus := "IDNbr"
oTable:cMainFile := Kolektor
oTable:cImageHome := ImageHome

oTable:acFields_ := { "COLLECTOR->F1", "COLLECTOR->F2", "COLLECTOR->F3",;
"COLLECTOR->F4", "COLLECTOR->F5", "COLLECTOR->F6",;
"COLLECTOR->F7" }
oTable:acHeaders_ := { "ID No.", "Surname", "First Name", "Second Name", "Middle Name",;
"Mobile No.", "Address"}
oTable:anWidths_ := { 80, 120, 120, 120, 120, 120, 300}

oTable:bTaskAdd := {|| GraphicUserInterface( "ADD" ) }
oTable:bTaskEdit := {|| GraphicUserInterface( "EDIT" ) }
oTable:bTaskExit := {|| BrowseWindowCloseEvent() }
oTable:bTaskDel := {|| DelRecord() }
oTable:bKpressInsert := {|| GraphicUserInterface( "ADD" ) }

oTable:bTaskWndInterActiveClose := { || BrowseWindowInterActiveClose() }
oTable:bKpressCtrlEnter := ""
oTable:bTaskDblClick := {|| GraphicUserInterface( "EDIT" ) }

IF lBTNExtra2
oTable:lExtra2 := lBTNExtra2
oTable:cExtraCaption2 := "Update Easter"
oTable:bTaskExtra2 := {|| EasterUpdate() }
ENDIF
IF TableDefinitions( @nBrowseType ) = Failure
BREAK
ENDIF

oTable:BeginBrowseDisplay( nBrowseType )

END SEQUENCE
DBCLOSEALL()
RELEASE WINDOW ALL
RETURN NIL

Code: Select all

///////////////////////////////////////////////////////////////////////////////////////////
CLASS GenericBrwObj                                                                      //
**************---------------------------------------------------------------------------//
// Purpose: HB CLASS handling of Tables, a generic table maintenance routine             //
///////////////////////////////////////////////////////////////////////////////////////////

   EXPORTED:
   
   DATA bTaskAdd
   DATA bTaskEdit
   DATA bTaskDel
   DATA bTaskPrint
   DATA bTaskExtra1
   DATA bTaskExtra2
   DATA bTaskExit
   DATA bTaskPrint
   DATA bTaskDblClick
   DATA bTaskOpen
   DATA bTaskClose
   DATA bTaskRelease
   DATA bTaskWndInterActiveClose
   
   DATA bKpressInsert   // shortcut: action when Insert key is press - default is nil
   DATA bKpressEscape   // shortcut: action when Escape key is press - defaul is nil
   DATA bKpressF1       // shortcut: action when F1 key is press - default is nil
   DATA bKpressF10      // shortcut: action when F10 key is press - default is nil
   DATA bKpressDel      // shortcut: action when Del key is press - default is nil
   DATA bKpressCtrlEnter
   
   DATA acFields_
   DATA acHeaders_
   DATA anWidths_
   DATA abHeadClicks_
   
   DATA cMainAlias
   DATA cMainFocus
   DATA cMainFile
   DATA cImageHome
   DATA cWndTitle
   DATA cQFind 
   
   DATA cExtraImage1
   DATA cExtraImage2
   DATA cExtraCaption1
   DATA cExtraCaption2
   DATA lExtra1         // logical variable to show or hide the Control Object Buton Extra 1, default is hidden
   DATA lExtra2         // logical variable to show or hide the Control Object Buton Extra 2, default is hidden
   
   DATA aColumnAlignment_
   DATA abrwImages_
   DATA cTooltip 
   
   METHOD New() CONSTRUCTOR
   METHOD BeginBrowseDisplay()
   METHOD BrowseRestoreFocus()
   METHOD BrowseCurrentPos()
   METHOD BrowseRefresh()
   METHOD AddNewRecod() INLINE EVAL( ::bTaskAdd )
   METHOD EditRecord() INLINE EVAL( ::bTaskEdit )
   METHOD DoPrintingJob() INLINE EVAL( ::bTaskPrint )
   METHOD ExtraButton1() INLINE EVAL( ::bTaskExtra1 )
   METHOD ExtraButton2() INLINE EVAL( ::bTaskExtra2 )
   METHOD Open() INLINE EVAL ( ::bTaskOpen )
   
   HIDDEN:
   METHOD DummyMsg()
   METHOD BrowseStatusChanged()
   METHOD QuickFindChanged()
   METHOD QFindLostfocus()
   METHOD DeleteKeyPress()
   METHOD Destroy()
   METHOD Close()
   
   END CLASS
   
   
   
********************************
METHOD New( ) CLASS GenericBrwObj

   ::bTaskAdd      := {|| ::DummyMsg() }
   ::bTaskEdit     := {|| ::DummyMsg() }
   ::bTaskDel      := {|| ::DummyMsg() }
   ::bTaskPrint    := {|| ::DummyMsg() }
   ::bTaskExit     := {|| ::DummyMsg() }
   ::bTaskExtra1   := {|| ::DummyMsg() }
   ::bTaskExtra2   := {|| ::DummyMsg() }
   ::bTaskExit     := {|| ::DummyMsg() }
   ::bTaskPrint    := {|| ::DummyMsg() }
   ::bTaskDblClick := {|| ::DummyMsg() }
   ::bTaskOpen     := {|| ::DummyMsg() }
   ::bTaskClose    := {|| ::DummyMsg() }
   ::bTaskRelease  := {|| ::DummyMsg() }
   ::bTaskWndInterActiveClose := {|| ::DummyMsg() }

   ::bKpressInsert := ""
   ::bKpressEscape := "" 
   ::bKpressF1     := ""
   ::bKpressF10    := ""
   ::bKpressDel    := ""
   ::bKpressCtrlEnter  := ""

   ::acFields_     := {}
   ::acHeaders_    := {}
   ::anWidths_     := {}
   ::abHeadClicks_ := { {|| ::DummyMsg( "No task is associated with this event", "DLBRW001" ) } }

   ::cMainAlias := ""
   ::cMainFocus := ""
   ::cMainFile  := ""
   ::cImageHome := ""
   ::cWndTitle  := ""
   ::cQFind     := ""
   
   ::cExtraImage1   := ""
   ::cExtraImage2   := ""
   ::cExtraCaption1 := ""
   ::cExtraCaption2 := ""
   
   ::lExtra1 := FALSE    // default is false, means do not show this button
   ::lExtra2 := FALSE    // default is false, means do not show this button
   
   ::aColumnAlignment_ := ""
   ::abrwImages_       := ""
   ::cToolTip          := ""
   
   
   RETURN Self
My question is given as such an example, will that be considered as part of HFCL or that is a separate library?

Thanks,

Danny
Regards,

Danny
Manila, Philippines
Post Reply