Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- RLIB 3.0a Reference - <b>function:</b> markrec() http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Function:    MARKREC()

Purpose:     Mark and select multiple records from a database pick list.

Syntax:      MARKREC( t, l, b, r, fieldlist, markkey, markfield, colors )

Arguments:   t,l,b,r     - Numeric values specifying the Top, Left, Bottom
                           and Right screen coordinates of the display
                           box.  The top and bottom row values must be
                           between 0 and 24 (MAXROW() in 5.0), and the
                           left and right column values must be between 0
                           and 79.

             fieldlist   - Character expression which evaluates to a field
                           list to be displayed at runtime.  This value is
                           macro substituted, so it must evaluate
                           correctly to a character string.  Any valid
                           expression may be used.

             markkey     - Optional mark/unmark key ASCII value which,
                           when pressed, toggles the current record being
                           included in a "marked" list.  If omitted or a
                           non-numeric value is passed the default ASCII
                           key value is -8, for the F9 key.

             markfield   - Optional field name or expression evaluated and
                           used to add an item to the marked list.  If
                           omitted or <markfield> is non-character in type
                           or empty, then the default expression used to
                           add items to the marked list is
                           "STR(RECNO(),8,0)"

             colors      - Optional array of color settings used to govern
                           the colors of various parts of the MARKREC()
                           display.  See the table listed below for
                           options and default values if the array is not
                           provided.

Returns:     A character string of selected record numbers, each eight
             digits long, delimited with a comma ",", or a null string if
             Escape was pressed.  If the optional <markfield> parameter is
             provided, the character string returned consists of elements
             added during the marking process.

Description: MARKREC() is a function for cursoring through a pick list
             selection of records from the currently selected database,
             and marking the records to work with by pressing a designated
             key (default = F9).  When the MARKREC() session is completed,
             MARKREC() returns a single character string which contains
             comma delimited tokens.  This string can then be parsed to
             extract each token in succession to process the records that
             were marked.

             MARKREC() lets a user select multiple records from a database
             to be included in some subsequent operation.  One such use is
             for prompting the user for records to include in a report.
             The user cursors up and down through a database pick list and
             presses a designated mark key to select each record.  When
             the user terminates by pressing the Enter key, MARKREC()
             returns a list of record numbers or field contents of the
             records selected.

Notes:       MARKREC() behaves very similar to PICKREC() except that
             instead if picking one record, you mark several records for
             processing.  MARKREC() skips forward and backward through the
             database records as the up and down arrow keys are pressed.
             The PgUp and PgDn scroll one window full of records.  When
             the Enter key is pressed, MARKREC() exits and returns a list
             of selected records in the form of a string of record
             numbers, each 8 digits with a comma delimiter.  For example,
             if the marked records were record numbers 5, 12 and 123, the
             string would be: "       5,      12,     123,".  Notice the
             trailing comma; a comma is added to the end of each selected
             record number.  To process the selected records you may use
             either FOR <data> $ string logic, or a loop to extract each
             record number to process.  See the example.  If the markfield
             parameter is supplied, this field (or expression) is
             extracted, and a trailing comma added to the end.  You can
             create your parsing loop based on the length of this field or
             expression.

             MARKREC() merely packages the parameters and makes a call to
             PICKREC() specifying the proper marking arguments.  See the
             PICKREC() function documentation for more details.  PICKREC()
             can be called directly.

             The elements of the color array are:

             Element#  Description                 Default              
             color[1]  Normal text display         Standard - SETCOLOR()
             color[2]  Selected or Marked          BRIGHT() Standard
             color[3]  Hi-lited (scroll bar)       Enhanced
             color[4]  Hi-lited & Selected/Marked  Enhanced/Bright/Blink
             color[5]  Color on exit from XITKEYS  BRIGHT() Standard
             color[6]  Normal text IF (color[8])   Standard - SETCOLOR()
             color[7]  Hi-lited IF (color[8])      Enhanced
             color[8]  Character condition         "(.T.)"

Example:     *-- database of customer orders, select orders to print
             *-- Orderno and Customer are fields in your database
             output = "Orderno + ' ' + Customer"

             *-- draw a double line box with a title header
             BORDERBOX( 1, 0, 22, 36, "CUSTOMER ORDERS" )

             *-- make the F5 key (INKEY() = -4) be the marking key
             marked = MARKREC( 4, 2, 21, 35, output, -4 )

             *-- now you can print information in one of two ways

             *-- Method #1
             REPORT FORM custrepo FOR STR(RECNO(),8,0)+"," $ marked
             *-- the comma on the end solves the problem of a mistaken
             *-- match from two record numbers concatenated together
             *-- "       110000000" = record 1 and 10000000, but would
             *-- match on record number 11 or 110 or 1100 etc...


             *-- Method #2 is a little more code but much quicker
             DO WHILE LEN(marked) > 0
                *-- get a record number from list (1st 8 digits in list)
                mrecord = VAL(SUBSTR(marked,1,8))
                *-- or you could do this another way
                *-- mrecord = VAL(GETPARM(1,marked))
                GOTO (mrecord)
                DO <your_report_printing_routine>
                *-- strip off first 9 characters (8 digits plus a comma)
                marked = SUBSTR(marked,10)
             ENDDO

Source:      RL_MARKR.PRG

See also:    GETPARM(), PICKREC()

See Also: GETPARM() PICKREC()

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