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>-></b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 ->
 Alias assignment--binary                        (Special)
------------------------------------------------------------------------------
 Syntax

     <idAlias>-><idField>
     <idAlias>->(<exp>)
     (<nWorkArea>)-><idField>
     (<nWorkArea>)->(<exp>)
     FIELD-><idVar>
     MEMVAR-><idVar>

 Operands

     <idAlias> is the name of the unselected work area to access and must
     refer to a work area with a database file in USE.

     <nWorkArea> is the number of the unselected work area to access.

     <idField> is the name of a field in the specified work area.

     <exp> is an expression of any data type to be executed in the
     specified work area.  If an expression more complicated than a single
     field reference is used as the second operand, the expression must be
     enclosed in parentheses (()).

     <idVar> is any valid CA-Clipper identifier.  Depending on whether
     you specify FIELD or MEMVAR, the identifier will be forced to a database
     field or memory variable (public or private) reference.

 Description

     When used with an <idAlias> as the first operand, the alias operator
     (->) accesses field information or evaluates an expression in the
     indicated work area.  The alias operator implicitly SELECTs the
     <idAlias> before evaluating the <idField> or <exp> operand.  When the
     evaluation is complete, the original work area is SELECTed again.  An
     alias reference can be in an expression or on a line by itself:

     ? Customer->Name
     Customer->(UpdateTransaction())

     Using the alias operator lets you:

     .  Access information from unselected work areas within
        expressions

     .  Access environmental information from unselected work areas

     .  Access information from unselected work areas in modes such as
        REPORT and LABEL FORMs

     .  Write more compact code

     In addition to allowing expression and field evaluation in unselected
     work areas, the alias operator makes an explicit reference to a field or
     variable using either the FIELD or the MEMVAR keyword aliases.  MEMVAR
     forces <idVar> to refer to a memory variable name, and FIELD forces it
     to reference a database field.  These special alias identifiers allow
     you to avoid ambiguity when there are conflicts between field and memory
     variable names.  Remember that a reference to a variable identifier not
     prefaced with an alias defaults to a field if there are both field and
     memory variables with the same name.  To override this, use the (/V)
     option when compiling.

     In addition to specifying the alias as an identifier, you can access the
     target work area using an expression that returns the work area number
     if the expression is enclosed by parentheses.  This lets you use work
     area numbers as handles which is useful for passing references to work
     areas without using macros, aliases, names, etc.

 Examples

     .  This example accesses database and work area information in an
        unselected work area:

        USE Customer NEW
        USE Invoices NEW
        ? Customer->CustName             // Result: Bill Smith
        ? Customer->(RECNO())            // Result: 1
        ? Customer->(FOUND())            // Result: .F.
        ? Customer->(City + ", " + State + ;
           "  " + Zip)                   // Result: ShadowVille,
                                         //         CA  90415

     .  This example uses a user-defined function (MySeek()) as an
        operand of the alias operator for a common operation that normally
        requires many more statements:

        IF Invoices->(MySeek(CustNum))
           <process customer>...
        ELSE
           <process no find>...
        ENDIF
        RETURN

        FUNCTION MySeek( cSearch )
           SEEK cSearch
        RETURN (FOUND())

        Note:  This example is just an illustration of the alias operator
        with a user-defined function.  CA-Clipper's DBSEEK() could be used
        instead of MySeek()

     .  This example explicitly references field and memory variables
        with the same name:

        USE Customer NEW
        MEMVAR->CustName = "Bill Smith"      // Create a memvar
                                             // CustName
        LOCATE FOR MEMVAR->CustName = FIELD->CustName

     .  This example uses an expression as a work area handle to
        create a work area-independent database operation:

        cTable1 := "C:Myfile.dbf"
        cTable2 := "D:Myfile.dbf"
        USE (cTable1) NEW
        hArea1 = SELECT()
        USE (cTable2) NEW
        hArea2 = SELECT()
        DoStuff( hArea1, hArea2 )

        FUNCTION DoStuff( hArea1, hArea2 )
           LOCAL nCount, nSave
           nSave := SELECT()
           SELECT (hArea1)
           FOR nCount := 1 TO FCOUNT()
              FIELDPUT( nCount, ( hArea2 )-> ;
                 ( FIELDGET( nCount )))
           NEXT
           SELECT (nSave)
           RETURN NIL

See Also: FIELD FIELDNAME() FIELDPOS() FIELDGET() SELECT

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