A new Xbase++-command: SBrowse  Download SBROWSE.ZIP  
 

 

Description:

   

And SBROWSE is a easy-to-use-Browser, which you can integrate with few lines of code in any Xbase-application and which dont require any further programming, has a lot of features and is fully customizable. It is full featured, changing of the collumn order or collumn or window.size is possible. All this "user-settings" are remembered for the next "SBROWSING" of this table. A reporting system and the possibility to export the browsed table or array to Excel is integrated.

Example:
#include "sbrowse.ch"
USE DTAUS SHARED
@0, 0, 20, 50 SBROWSE PARENT setAppwindow() TITLE "TEST" MODAL

Result:


 


With SBrowse (SimpleBrowse) it is very easy to browse tables or arrays in a XbpDialog-window with a nice standard toolbar, which allows seeking and locating in tables, sorting and switching between indexes, exporting the table to excel or printing the table with (or without) a Reportingsystem.

The toolbar above allows (from left to right): Exit, Down, Up, Seek/Locate, Exit&select data, Left, Right, Go bottom, Go top, Print, Excel-Export, Show table with Explorer, Delete column, Insert column, Switch beetween several color-modes, Help for SBrowse. For all options in the toolbar there are shortcuts too.

The parameters nTop, nLeft, nBotton, nRight are standing for the size and position of the dialog for the very first time you call the code. Of course you can change the position and the size. The second time you call the code, the changed size and position is restored without caring about it.


A wide range of configuration and customizing abilities allows to customize the SBrowse in detail, but what you should know here is, not the programmer has to do this work, customizing can be done by the user:

In the implemented view the user is able to mask collums (delete columns from the view), also  the order of the columns and the column-size can be changed. The next time the table is "recalled", exactly the same view is restored. Also the size and the position of the SBrowse-window is restored.

SBrowse is based on XbpBrowse and XbpDialog and is "threadsave" (can be called several times in the same program with the same or with different tables whithout conflicts). It is DBE-independent (there exists an optimized version for ADSDBE too) and can effectivly handle arrays up to several MBytes.

SBrowse needs only an actual foundation subscription (plus BAP.DLL, which is downloadable from Alaska) to work.

SBrowse can  automatically handle known tables more in detail, whith a integrated datadictionary. The datadictionary is useful to create an abstraction-level to the database (e.g. physical table- index- and fieldnames are not visible any more to the user, however the user can work with it) and give the user a better understanding of the datastructur. Further it help to reduce the code, which has to be written to get good results. SBrowse will work with the datadictionary, if it is installed. To the datadictionary belongs a administration tool,  which is based on SBrowse. The description of this feature is not part of this documentation. If you are interested to use the datadictionary, give me a mail.

Example 2:

Same like example 1 only with the edit-option

#include "sbrowse.ch"
USE TABLE SHARED
@ 9,1,18,78 SBrowse PARENT setAppwindow() TITLE "TEST" MODAL OPTEDIT

Result (Please remark the additional Edit-button):

Example 3:

Now we customize the headerArea and we add a delete-button and a tab-button, because we pass a DELBLOCK and a TABBLOCK:

#include "sbrowse.ch"
USE DTAUS SHARED

aFields :=;
    {;
    { "Personen;-Konto", "PKTO",                        , },;
    { "Kurz;-Text",      "PKTOKURZ",       "@!"         , },;	  // PICT allowed
    { ";Blz",            "Blz",            5            , },;     // LEN (field) allowed
    { ";Konto-Nr",       "KontoNr",                     , },;
    { ";Bank",           {|| FIELD->Bank },             , },;     // blocks
accepted
    { ";BelegDat",       "Belegdatum",                  , },;
    { "; Betrag",        "ZBetrag",       "@E 9,999.99" , };      // PICT allowed
}
@ 9,1,18,78 SBrowse PARENT setAppwindow() ;
	TITLE "TEST" ;
        MODAL ;
	FIELDS aFields ;
	OPTDEL ;
	OPTEDIT ;
	TABBLOCK  { |a,b| MyTab(a,b) } ;
	DELBLOCK  { |a,b| MyDel(a,b) } 

Result (remark the different headers):



Example 4

Different colors for each row are possible, depending on the values of the shown records. Further it is possible to show additional information in the head or foot of the table. We can use the option TOPBOTTOMSPACE to get additional space. In the INITBLOCK we can create some Sle´s which show additional information for the current row: With the MARKEDBLOCK we refresh their values. When resizing the XbpDialog-window, the additional information is automatically excluded from resizing, nomatter if on top or in the bottom. 



Example 5:

Even more complex views are possible. The next view shows a master (a unique key from the same or another table) that is used to select (in the slave) a subset of record to show / edit. The master is on the right the slave on the left side. It is no problem to change the inputfocus between master and slave.


Here is the code for that:

aMasterFields :=;
	{;
		{ "HH-;Plan-;Nr", {|| Plan_Nr }, , 6 }, ;
		{ ";;Text", { || substr( TEXT, 1, 20 ) }, 20, };
	}

aMaster :=;
	{;
		2 ,; 					// 1 The select-Area, where the mastertable ist opened
		6 ,; 					// 2 ord-number of index (mostly a unique-Key or another table)
		aMasterFields,; 			// 3 field-description
		{|| FIELD->PLAN_NR },; 			// 4 masterkey
		1 ,; 					// 5 Column that contains the index
		"",; 					// 6 additional text to show
		,; 					// 7 unUsed
		"KTO" ,; 				// 8 slave-DBF-Alias
		5 ,; 					// 9 slave-Indexord
		{ || FIELD->PLAN_NR } ,;		// 10 slavekey
		{ || NIL },; 				// 11 slave-killinputfocus-block
		0,; 					// 12 free additional space for head by setinputfocus(Slave)
		0,; 					// 13 free additional space for foot by setinputfocus(Slave)
		{ 0, 0 }, ; 				// 14 { aPos }, X, Y (max 999 ) }
		NIL; 					// 15 unused
	}

@ 0,0,24,79 sBrowse PARENT setAppwindow();
	TITLE "Finanzstatistik-Konten" ;
	FIELDS aFields ;
	OPTDEL ;
	OPTEDIT ;
	OPTNEW ;
	INITBLOCK   { |a,b| ShwKtoInit( a, b, 3, 21) };
	MARKEDBLOCK { |a,b| ShwKto( a, b) } ;
	MASTER aMaster

That is all what has to be done for the complex view above. Now there is only missing the the INITBLOCK and the MARKEDBLOCK for the additional information in the head or in the bottom. The code for the MARKEDBLOCK is normaly quit short, the code of the INITBLOCK can be longer, depending on the amount of fields you like to show in the head or the footarea.

func ShwKto( oDlg, oBrowse )
    MyRefresh( oBrowse:GetList )
return NIL

Remember that you can drop one ore more collums, you can resort the sequence of the collums, you can resize the collums you can change the size of the XbpDialog and all will be restore the next time you call the same SBrowse-code.

The full syntax of this command is mostly "self-explaining".

Syntax:

@ nTop, nLeft, nBotton, nRight SBrowse ;
	PARENT oParent ;
	[ MODAL ] ;
	[ OPTEDIT ] ;
	[ OPTNEW ] ;
	[ OPTDEL ] ;
	[ OPTSHOWDEL ] ;
	[ OPTSECONDROW ] ;
	[ FIELDS abFields ] ;
        [ DATAARRAY aTable ]
	[ OPTIONS aOptions ] ;
	[ COLOR cColor ] ;
	[ TITLE cTitle ] ;
	[ INITBLOCK bInit ] ;
	[ MARKEDBLOCK bMarked ] ;
	[ TABBLOCK bTab ] ;
	[ PRINTBLOCK bPrint ] ;
	[ DELBLOCK bDel ] ;
	[ TOPBOTTOMSPACE aExtraSpace ] ;
	[ SIMPLEEDITBLOCK bEditSimple ] ;
	[ EDITBLOCK bEdit ] ;
	[ MASTER aMaster ];
	[ TO <output> ]
 

nTop, nLeft, nBotton, nRight: This parameters are standing for the size and position of the dialog for the very first time you call the code and produce a specific view . Once created it is possible to change the position and size. The changed size and position is automatically restored at all following calls of a view  .

PARENT In case of use of the option MODAL this parameter should not be empty and contain a XbpCrt or a XbpDialog-window.

MODAL The option MODAL makes the SBROWSE-window modal. The minimize-pushbotton is disabled with MODAL. Designed for "popup-windows" called when during editing a XbpSle.

OPTEDIT The option OPTEDIT allows editing the data. An "edit pushbutton" will be created.

OPTNEW The option OPTNEW allows appending new data to the table. A "new-pushbutton" will be created.

OPTDEL The option OPTDEL allows deleting data. A "delete-pushbutton" will be created. See DELBLOCK too.

OPTSHOWDEL The option OPTSHOWDEL allows viewing deleted data. Without this option, deleted data is not shown.

OPTSECONDROW The option OPTSECONDROW allows to position the cursor in the second row of the table, after creating the browse without performing any skips in SBrowse.

FIELDS This parameter describes the header and the presentaion of the data. Can be  NIL | {{array}} | block->{{array}}
(read like this: fields can be NIL .OR. a 2dim-array  .OR. a codeblock which returns a 2dim array)

With the FIELDS-parameter you chose one of 2 modes.

In case of NIL a standard-format is chosen, all datafields are shown. You can delete them in the view.

In case of passing an array, the array has to be in the format { "headertext", "fieldname" | block->string }

All following parameters are optional and can be

3th param-> NIL | picture (see Xbase-function transform() or a value for the field-length (substr) )
4th param-> NIL | indexord
5th param-> NIL | String: Add this constant when seeking like: seek constant + what_i_typed
6th param-> NIL | String used as seek rule : "*" ->Inteligent seeking  
7th param->internal
8th param-> NIL | String for describing the edit-mode. This can be "XBPGET"|"NORMAL". Only with XBPGET it is possible to edit directly in the table.

DATAARRAY Can be  NIL | {array of recno} | { {{array}}, StartRecno }| { block->{{array}}, StartRecno }. In case an array of record numbers is passed, SBrowse shows only the equivalent records in the view. "Real" data has to be passed in the form of a 2 dim Array, like { { "row 1 date1", " row 1 date2" },  { "row 2 date1", " row 2 date2" }, ... }. This data-array has to be the first element of another array like {aData, nStartRecno}. When this parameter is passed, the FIELDS-Parameter must not be empty. When a data-array is browse the view allows to sort the shown data on every column.

TITLE The title of the XbpDialog-window, which contains the browse: The XbpDialog can be customized more detailed in the INITBLOCK.

The INITBLOCK called before showing the XbpDialog-window. There are passed the (Xbp)Dialog and the (Xbp)Browse to it as parameters. Use for detailled configuration. The return value of the block is stored in the IVar (Xbp)Browse:GetList

MARKEDBLOCK. There are passed the XbpDialog and the XbpBrowse to the block as parameters. No return value.

DELBLOCK. This block is called, when trying to delete a record. There are passed the XbpDialog and the XbpBrowse to the block as parameters. With return .T. there is performed a refreshAll(). Remark: Without  OPTDEL you can´t delete a record. With  OPTDEL but without  DELBLOCK a standard delete-action is performed.

TABBLOCK. This block is called, when pressing the tab-key or using the tab-button in the toolbar. There are passed the XbpDialog and the XbpBrowse to the block as parameters. With return .T. there is performed a refreshAll(). Remark: Without  DELBLOCK there will be performed no action. Also the tab-button will not be visible.

PRINTBLOCK. This block is called, when using the print-button in the toolbar. There are passed the XbpDialog and the XbpBrowse to the block as parameters. Remark: Without  PRINTBLOCK there will be performed a standard print action, which is based on a well known standard reporting module.

SIMPLEEDITBLOCK. This block is called, when pressing <Return> or <Insert>  or using the edit-button or new-button in the toolbar. There are passed XbpDialog ,XbpBrowse, lEditAllowed, lNewAllowed to the block as parameters. The record is automatically locked and unlocked. In case of new, there is performed a APPEND BLANK before calleing the SIMPLEEDITBLOCK. Remark: Use EDITBLOCK to implement a more customized edit-action.

EDITBLOCK. This block is called, when pressing <Return> or <Insert>  or using the edit-button or new-button in the toolbar in case you did not defined a SIMPLEEDITBLOCK. There are passed XbpDialog ,XbpBrowse, lEditAllowed, lNewAllowed to the block as parameters. The edited record are not automatically locked and unlocked. In case of new, there is NOT performed a APPEND BLANK. IN case of editing a Memo-Field there is called a RTF-Control. When the RTF-Control is not installed there is used a variant of MemoEdit(). Remark: Without  SIMPLEEDITBLOCK and without EDITBLOCK there will be performed a standard edit-action, when OPTEDIT was passed.

MASTER. The MASTER-option is used to produce a "master-browse" which controls, what records are shown in the "slave-browse". When clicking in the slave-browse its behavior is like a "normal" SBrowse, the only difference is, that it shows still a subset of records of the table. All blocks which are passed affect only the slave-browse. When using the MASTER-option a array with 15 Elements has to be passed:

1 select-area, where the mastertable is opened
2 ord-number of index (mostly a unique-key or another table)
3 field-description (for the structur see parameter FIELDS above)
4 masterkey which is use to find the slave-records
5 column that contains the index of the master-table
6 additional text to show, currently not implemented
7 unused
8 slave-dbf-Alias
9 slave-indexord
10 slave-key
11 slave-killinputfocus-block, can be { || NIL} too
12 free additional space for head by setinputfocus(Slave)
13 free additional space for foot by setinputfocus(Slave)
14 aPos { X, Y } (max. {999, 999} )
15 unused

Remarks

Pressing K_CTRL while building the SBrowse will restore all masked columns and set the order of the columns to default. Pressing K_CTRL .AND. K_ALT while leaving the SBrowse set the view to standard when recalling the same view. Masking all columns (no columns more visible in the view) will have the same effect..

To change the column-order delete one column and insert it at another position.

To select a record from the table with Crtl-Return. When SBrowse is finished, ask for lastkey() = K_CRTL_RET to see if data was selected.

Press K_CTRL_F5 to build and remember complex queries (only if dclip1.dll is in the path)

The key K_CRTL_D in SBrowse will call DC_DOT (if dclip1.dll is in the path)

Start a Helpthread with oToolTip := MyMagicHelp():New(); oToolTip:start() to get tooltips for the SBrowse-buttons

SBrowse can only restore the order of the columns in the current version  when using the FIELDS-Parameter.

Download SBROWSE.ZIP

Contents of the Libs, which are contained in SBROWSE.ZIP

and much more which should all be in a future documention.