Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Mouse interface routines - <b>browse</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 BROWSE
 Browse command to activate browse with mouse
------------------------------------------------------------------------------
 Syntax
      BROWSE <aFields>, <nTop>, <nLeft>, <nBottom>, <nRight> TO <nRecNum>;
             [WHILE <bWhile>];
             [KEY <cKey>];
             [FREEZE <nFreeze>];
             [<SAVESCREEN>];
             [COLORS <cColorList>];
             [SCREENINIT <bScreenInit>];
             [READINIT <nReadInit>];
             [ALTREAD <bAltReader>];
             [EXIT <nExitKey>];
             [<APPEND>];
             [APPREAD <bAppendReader>];
             [RECORDNUM <bRecordNum>];
             [RECORDTOTAL <bRecordTotal>]
 Arguments
     <aFields> is multidimensional array of field blocks of fields you
        want to display. Each row contains up to six members containing:

        Index 1: Column heading
        Index 2: Code block for displaying information. Note: if you are
                 going to do an a read, this must code block must be written
                 so that if a parameter is passed, it will set the GET
                 variable. For example: {|x| IIF(x=NIL,Last,Last:=x) }
                 can be used by both browse and the GET system.
        Index 3: Optional logical indicating if field can be edited if you
                 are allowing edits. By default, if you are allowing edits
                 (see below) it is .T., and, obviously, if you are not .F.
        Index 4: Optional Picture function for get on this column.
        Index 5: Optional Code block to be executed as a WHEN clause.
        Index 6: Optional Code block to be executed as a VALID clause.

        Example to set up last name and first name in array:
        aFields := {}
        AADD(aFields, {"Last Name", {||Names->Last}, .T., "!XXXXXXXXXXXXXX" })
        AADD(aFields, {"First Name", {||Names->First} } )

     <nTop>, <nLeft>, <nBottom>, <nRight> are the coordinates of
        the area to display the TBrowse in.  Defaults to 2, 2,
        MaxRow(), MaxCol() i.e. full screen.

     <bWhile> is the limiting WHILE condition as a block.
        If cKey (below) is NIL. This is automatically set to {|| .T.}.
        If you will be allowing appends you will want to allow arguments to
        be passed so that you can use this while block on data entered by the
        user prior to adding it to the database. The third example below
        shows such a block (as does the example program above).

        Example 1: { ||Names->Last == "JONES" }
        Example 2: { ||Names->Last == "JONES" .AND. Names->First == "A"  }
        Example 3: { |x| IIF(x=NIL, Names->Last = cKey, x = cKey)}

     <cKey> is the key to find top condition of WHILE.
        If NIL the entire database is browsed.
        cLast  := "JONES     "
        cFirst := "A"
        Example 1: cKey := cLast
        Example 2: cKey := cLast + cFirst

     <nFreeze> is number of fields to freeze in TBrowse.  Defaults
        to 0 if not passed.

     <SAVESCREEN> - If present the screen will be saved

     <cColorList> is a list of colors for the TBrowse columns.
     The 1st color is used as SAY/TBrowse Background and the
     3rd and 4th colors are used as part of column:defColor := {3, 4}

     Thus if you pass a cColorList, you MUST pass at least 4 colors.
     Defaults to "N/W, N/BG, B/W, B/BG, B/W, B/BG, R/W, B/R" if not passed.

     <bInit> is a code block which calls a routine to initialize the
          screen after it has been cleared. You could place help or
          mouse hot spots on the screen with this routine. If not included
          then nothing happens.

     <nReadInit> indicates how a read is initiated. The constants
          GET_ON_RETURN and DOUBLE_CLICK_GET are defined in MBROWSE.CH.
          GET_ON_RETURN indicates that a return will initiate a GET on
          the current field. DOUBLE_CLICK_GET indicates that a mouse
          double click will initiate a GET on the current field. Either
          one or the sum of the two can be used to indicate how to initiate
          a GET. Passing NO_GET or NIL will prevent any editing.

          Example:
            GET_ON_RETURN+DOUBLE_CLICK_GET   will allow both the mouse and
                                             return initiated gets

     <bAltReader> is a code block which is called in place of the internal
          reader when the user requests an edit. If not passed then the
          internal one is called. This gives more flexibility in doing
          reads and actually can be used for functions other than reads
          (especially with the mouse). See the function DoGet for details
          of what must be passed.

     <nExitKey> is a InKey code of a key which will exit the
          browse other than the escape key which is always active. By
          default is is set to K_RETURN if GETS are not allowed and
          nothing if they are allowed.

     <APPEND> indicates if appends to the database are allowed.

     <bAppendReader> is a code block which will perform a read and append
           when the user requests an append. The routine receives no
           arguments but must return the number of records meeting the
           current while condition that were appended to the database.
           NOTE: if you are appending records under a while condition, do
           not include records which you may have added but which do not
           meet the criteria.

     <bRecordNum> Is an optional code block which will return the
           sequence number of the current record within the current scope
           including the influence of any WHILE clause given to the browse.
           The value is used in presenting the scroll bar. It returns
           the record number of the current record. Unless you are using
           the natural order of the database, this value is NOT equal to
           RECNO(). If the argument is not given, then the default routine
           is used. One might use this routine if one knows, for example,
           that only 1% of a very large database will be used for the
           browse and you have a faster way of counting than the default
           method.

     <bRecordTotal> is an optional code block which returns the total number
           of records which fall under the scope of the browse. Note: if the
           database contains deleted records the value of LASTREC() is
           incorrect if set deleted is on. If no value is given then the
           the default method is used when scroll bars are in use.
 Returns
     <nRecNum> is the number of the record selected by the <nExitKey> key.
           0 is returned if there are either no records matching the WHILE
           condition or an <Esc> is pressed instead of an <Enter> or the
           defined exit key.

 Description
     This is a command which simplifies calling MBROWSE(). Its definition
     is actually in MBROWSE.CH
 Examples
   #include "mbrowse.ch"

   bWhile={|x| IIF(x=NIL,LEFT(TBNames->Last,1) == cKey, LEFT(x,1) == cKey)}
   BROWSE aFields, 3, 4, maxrow()-2, maxcol()-2 TO nRecSel WHILE bWhile ;
        KEY cKey SCREENINIT bScreeninit SAVESCREEN FREEZE nFreeze ;
        COLORS cColorList READINIT GET_ON_RETURN+DOUBLE_CLICK_GET ;
        EXIT K_ALT_E APPEND APPREAD {|| myReader()}

 Header File: MBROWSE.CH


 Source: MBROWSE.CH

 Author: Leo Letendre

See Also: MBROWSE()

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