Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- CA-Clipper 5.2 . The Guide To CA-Clippe - <b>notes</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 Notes

     .  WHEN and VALID: The expressions specified in the WHEN and
        VALID clauses may be of arbitrary complexity and may include calls to
        user-defined functions.  This is useful for attaching automatic
        actions to the activation or deactivation of a GET.

     .  Assigning <idVar>: Because of the automatic refresh and
        display properties of a Get object while it is being READ, you can
        make an explicit assignment to the Get object's <idVar> within a WHEN
        or VALID expression.  You can directly assign the variable by name in
        the validation expression or, for private, public, local, or static
        variables, by passing a reference to <idVar> to a function; the
        function can then assign <idVar> by assigning the corresponding
        formal parameter.  If <idVar> is a field, it is globally visible and
        can be assigned by name in a function called by the validation
        expression.

        When including a Get in a called function, do not include an <idVar>
        with the same name as a field <idVar>.  Field references have
        precedence over public variables so the public <idVar> will be
        ignored.

     .  GET specific help: You can use a SET KEY procedure to display
        help text associated with a Get object.  Within the SET KEY
        procedure, use the READVAR() function to determine the <idVar>
        associated with the current Get object.  Use this information to
        display the appropriate help text.  Remember that when a
        CA-Clipper-compiled program loads, the F1 KEY is automatically
        SET TO a procedure or user-defined function named Help.

     .  SET DEVICE TO PRINTER: SET DEVICE TO PRINTER does not direct
        display of a Get object under the @...GET command to the printer or
        file.

 Examples

     .  This  example uses the VALID clause to validate input into a
        GET:

        LOCAL nNumber := 0
        @ 10, 10 SAY "Enter a number:" ;
           GET nNumber VALID nNumber > 0

     .  This example demostrates passing a code block with the VALID
        clause.  The parameter oGet is the current get object.  Udf() changes
        the value of the GET:

        LOCAL GetList := {}, cVar := SPACE(10)
        CLS
        @ 10, 10 GET cVar  VALID { |oGet| Udf1( oGet ) }
        READ
        .
        .
        .
        * Udf( <oGet> ) --> .T.

        FUNCTION Udf1( oGet )

        IF "test" $ oGet:BUFFER          // Compare buffer contents
        oGet:varPut( "new value " )      // Change contents
        ENDIF

        RETURN .T.

     .  This example uses the WHEN clause to prohibit entry into GETs
        based on the value of another GET.  In this example, entering Y in
        the Insured field indicates the client has insurance and the user is
        allowed to enter insurance information.  If the client does not have
        insurance, the cursor moves to the Accident field:

        @ 10, 10 GET Insured PICTURE "Y"
        @ 11, 10 GET InsNumber WHEN Insured
        @ 12, 10 GET InsCompany WHEN Insured
        @ 13, 10 GET Accident PICTURE "Y"
        READ

     .  This is an example of a GET in a secondary work area:

        USE Invoice NEW
        APPEND BLANK
        USE Inventory NEW
        @ 1, 1 GET Invoice->CustNo
        READ

     .  This example uses the @K function to suggest a default input
        value, but deletes it if the first key pressed is not a cursor key or
        Return:

        LOCAL cFile := "Accounts"
        @ 1, 1 SAY "Enter file" GET cFile PICTURE "@K"
        READ

     .  This is an example of a nested READ using GetList and lexical
        scoping:

        #include "inkey.ch"
        //
        // Local to this function only
        LOCAL GetList := {}
        LOCAL cName   := SPACE( 10 )
        //
        CLS
        SETKEY( K_F2, { || MiscInfo() } )   // Hot key to special READ
        //
        // Get object added to Getlist
        // works on local getlist
        @ 10, 10 SAY "Name" GET cName
        READ
        //
        RETURN NIL

        /***
        *  MiscInfo() ---> NIL
        */
        FUNCTION MiscInfo()
        //
        LOCAL GetList    := {}               // Local to this
        LOCAL cExtraInfo := SPACE( 30 )      // function only
        //
        // Get object added to getlist
        // works on local getlist
        @ 12, 10 SAY "Note: " GET cExtraInfo
        READ
        //
        RETURN NIL

 Files:  Library is CLIPPER.LIB.

See Also: @...SAY COL() READ SETCOLOR() Picture codes Colors

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