Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- TSDWIN: Clipper 5.0 Interface Library - Norton Guide http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]

 twBRBrowse() Example Function Calls
 ----------------------------------------------------------------------------

       Example:

       This is an example from an actual application:

     PROCEDURE BrowseFile() 
     // LIST  FROM Application Maintenance
     LOCAL oDB, aActionKeys := {}, aColumns := {}, aHotSpots := {}
     LOCAL nBOrder := 1, cTitle := '', nCount
     LOCAL aBarColor := twListAsArray( MCOLORN )
     LOCAL nBar1 := twVAttr( aBarColor[ 2 ] )
     LOCAL nBar2 := twVAttr( aBarColor[ 5 ] )

     // Open Files
     UseFile( "MEMBERS", .F., 0 )
     GO TOP
     UseFile( "SHOW", .F., 0 )
     UseFile( "HOBBY", .F., 0 )
     UseFile( "CODES", .F., 0 )
     UseFile( "SHOWCODES", .F., 0 )

     // Open a Window
     twOpen( 1, 0, 23, 79, MCOLORW, YSHADOW, YFRAME,, MCOLORFW )

     // disolay hot spot areas and choices
     twInfoLine( -2, ;
        ".ENTER..Edit .DEL..Delete .INS..Add .F1..Help " + ;
        ".F2..Order .F3..Active .A-Z:1-9..Search .ESC..Quit", "P" )
     SELECT Members
     SET ORDER TO 4
     GO TOP

     // Construct column calls
     AADD( aColumns, { "Member Name", ;
                             {|| PADR( ALLTRIM( Members->Lname ) + ;
                             IIF( !EMPTY( Members->Lname ), ", ", "" ) + ;
                             ALLTRIM( Members->Fname ) + ;
                             " " + ALLTRIM( Members->Init ), 30 ) }
                             ,,,,,,,, { 1, 2 },
                     {|| IIF( Members->Active, { 4, 2 }, {  6, 5 }) } } )
     AADD( aColumns, { "Member;Number", ;
                {|| Members->Memnum },,,,,,,, { 1, 2 },;
                {|| IIF( Members->Active, { 1, 2 }, {  6, 5 }) } } )
     AADD( aColumns, { "Application;Number",;
                {|| Members->AppNum },,,,,,,, { 1, 2 },;
                {|| IIF( Members->Active, { 1, 2 }, {  6, 5 }) } } )
     AADD( aColumns, { "Member;Status",;
                {|| Members->Status },,,,,,,, { 1, 2 },;
                {|| IIF( Members->Active, { 1, 2 }, {  6, 5 }) } } )
     AADD( aColumns, { "Postal;Code",;
                {|| Members->Postal },,,,,,,, { 1, 2 },;
                {|| IIF( Members->Active, { 1, 2 }, {  6, 5 }) } } )

     // initial title for browse
     cTitle := PADC( "Membership File Ordered by Name", 38 )

     // add hot spots to browse and get handles for releasing memory
     AADD( aHotSpots, twBRHotSpot( 24, 01, 24, 09, ;
                     {|| TSDGet( .F., aHotSpots ) }, 1,, .T. ))
     AADD( aHotSpots, twBRHotSpot( 24, 11, 24, 21, ;
                     {|| TSDDel() }, 1,, .T. ))
     AADD( aHotSpots, twBRHotSpot( 24, 22, 24, 28, ;
                     {|| TSDGet( .T., aHotSpots ) }, 1,, .T. ))
     AADD( aHotSpots, twBRHotSpot( 24, 30, 24, 36, ;
                     {|| TSDHelp( aHotSpots ) }, 1,, .T. ))
     AADD( aHotSpots, twBRHotSpot( 24, 38, 24, 45, ;
                     {|| TSDOrder( @nBOrder ) }, 1,, .T. ))
     AADD( aHotSpots, twBRHotSpot( 24, 47, 24, 55, ;
                     {|| TSDActivate() }, 1,, .T. ))
     AADD( aHotSpots, twBRHotSpot( 24, 72, 24, 79, ;
                     {|| __keyboard( CHR( K_ESC )) }, 1,, .T. ))

     // add actionkeys to browse
     aActionKeys := { { K_ENTER, {|| TSDGet( .F., aHotSpots )  }},;
                      { K_INS,   {|| TSDGet( .T., aHotSpots )   }},;
                      { K_DEL,   {|| TSDDel()   }},;
                      { K_F1,    {|| TSDHelp( aHotSpots )  }},;
                      { K_F2,    {|| TSDOrder( @nBOrder ) }},;
                      { K_F3,    {|| TSDActivate() }} }

     twBRBrowse( 1, 0, 23, 79, aColumns, cTitle,, ;
                 ,, aActionKeys, MCOLORN, YSHADOW, YFRAME, ;
                 MCOLORFN, .T.,, .F., 1, .F., ;
          {|| twTitle( PADC( "Membership File Ordered by Name", 38 ), TCOLOR ) };
                 ,,,,,,, {|| IIF( Members->Active, nBar1, nBar2 ) })

     // release  hot spot handles
     FOR nCount = 1 TO LEN( aHotSpots )
         twBRRemHotSpot( aHotSpots[ nCount ] )
     NEXT

     //  Close files
     CLOSE Members
     CLOSE Codes
     CLOSE ShowCodes

     RETURN

     This example uses the search array:

     USE Phone INDEX Phone1, Phone2, Phone3 ALIAS Names NEW
     aColumns := {}
     cTitle := { "Dynamic Search on Third Field", "w+/bg", "B", "R" }
     SETBLINK( .F. )

     AADD(aColumns, { 'Person;Name' , ;
                 {|| PADR( Names->lname ) + ', ' +;
                         TRIM( Names->fname ) + ' ' +;
                         TRIM( Names->init ), 19 )},,,,,,,,;
                         ,,,,,,,,{4,2},{||IF(DELETED(),{7,2},{4,2})}})

     AADD(aColumns, { 'Company;Name', ;
                 {|| SUBSTR( Names->company, 1, 16 )},,,,,,,,;
                         {1,2},{||IF(DELETED(),{7,2},{1,2}) }} )

     AADD( aColumns, { 'Work;Phone',
            {|| TRANSFORM( Names->wphone, "@R (999) 999-9999" )},,,,,,,,;
                         {1,2},{||IF(DELETED(),{7,2},{1,2}) } })
     AADD( aColumns, { 'FAX;Phone', ;
            {|| TRANSFORM( Names->fphone, "@R (999) 999-9999" )},,,,,,,,;
                          {1,2},{||IF(DELETED(),{7,2},{1,2}) } })

     SET ORDER TO 3
     // aSrch array structure
     //
     //  { Column Number in which to start key display,
     //    Hilite Bar Exception Color
     //    Code block for search access to dbf.
     //    Prefix for common keys in scoped browses,
     //    Mask for display bar. }

     aSrch := { 3, "n/*gr",, "416", "X   XX   X    X    X" }
     cTopKey := "416"
     bScopeBlock := {|x| IIF( x=NIL, ;
          LEFT( Names->wphone, 3 ) == cTopKey, LEFT( x, 3 ) == cTopKey )}

     // you must define all the other parameters, of course.

     twBRBrowse( wT, wL, wB, wR, aColumns, cTitle, cTopKey, ;
              bScopeBlock, lEditFlag, aActionKeys, wColor, wSType, wFType,;
              wFColor, lScBar, lMsgs, lAlite, nFreeze, lStabilize, ;
              bPreRun, bPostRun, nExitKey, aSeparators, lOKAppend, ;
              lSound, lWindow, bBarColor, aSrch )

See Also: twBRBrowse()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson