While we need to write this kind of code for twbrowse or tcbrowse, xbrowse made browing arrays very simple.
The command :
- Code: Select all Expand view RUN
@ 0,0 XBROWSE oBrw OF oWnd ARRAY aData AUTOCOLS
is all that is needed to browse the entire array.
If we like to browse only selected columns, say 3rd, 2nd and 5th columns only of the array
- Code: Select all Expand view RUN
@ 0,0 XBROWSE oBrw ;
COLUMNS 3, 2, 5 ;
HEADERS "First", "Second", "Third" ;
OF oWnd ;
ARRAY aData
is enough. Even the array elements can be of any datatype, xbrowse handles the necessary conversions.
If we still want to use the traditional tcbrowse command syntax, that is also possible to add columns ( even to insert the new column ).
If we prefer to continue the old TXBrowse way of using methods and data,
- Code: Select all Expand view RUN
oCol := oBrw:AddCol()
oCol:nArryCol := 5 // this is enough
// Instead of the earlier
// oCol:bStrData := {|| cValToChar( oBrw:aArrayData[ oBrw:nArrayAt ] ) }
// Writing this for eacj column
// or looping through the array to build the blocks taking advantage of detached locals
No need to code with oBrw:aArrayData oBrw:nArrayAt or oBrw:nAt(), etc. though thiose options are still available if we enjoy writing long pages of code.
In addition we have facilities like autosort, report, export to excel, etc.
Xbrowse command syntax is almost similar to ListBox and TCBrowse syntaxes, so that we write the code the familiar way but in just a fewer lines than what is necessary with earlier xbrowse or its elder brothers wbrowse or tcbrowse.
When I am converting my earlier xbrowse code using the new facilities, multiple pages of code is now fitting into a page or less. Better readability and easy to maintain.
8.03 allows browsing blank recordsets. Wish we can browse blank arrays too in some way.