: Send

 


 :
 Send--binary                                    (Object)
------------------------------------------------------------------------------
 Syntax

     <object>:<message>[(<argument list>)]

 Type

     Object

 Operands

     <object> is the name of the object that is to receive the message.

     <message> is the name of a method or instance variable.

     <argument list> is a list of parameters that are passed to the
     specified message.  The parentheses surrounding the argument list are
     optional if no parameters are supplied in the message send.  By
     convention, however, parentheses distinguish a message send with no
     parameters from an access to an exported instance variable.

 Description

     Each class defines a set of operations that can be performed on objects
     of that class.  Perform these operations by sending a message to the
     object using the send operator (:).

     When a message is sent to an object, the system examines the message.
     If the object is of a class that defines an operation for that message,
     the system automatically invokes a method to perform the operation on
     the specified object.  If the class does not define a method for the
     specified message, a runtime error occurs.

     Executing a message send produces a return value, much like a function
     call.  The return value varies depending on the operation performed.

 Examples

     .  In this example, myBrowse is the name of a variable that
        contains a TBrowse object reference.  pageUp() is a method that
        specifies the operation to be performed.  The available operations
        and corresponding methods vary depending on the class of the object.
        The Error, Get, TBColumn, and TBrowse classes are documented in this
        chapter.

        myBrowse:pageUp()

     .  This example forces the checkbox state to true (.T.):

        myCheck : Select (.T.)

.OR. Logical OR

.OR.
 Logical OR--binary                              (Logical)
------------------------------------------------------------------------------
 Syntax

     <lCondition1> .OR. <lCondition2>

 Type

     Logical

 Operands

     <lCondition1> and <lCondition2> are logical expressions.

 Description

     The .OR. operator is a binary logical operator that executes a logical
     OR operation using the following modified Boolean rules:

     .  Returns true (.T.) if either <lCondition1> or <lCondition2>
        evaluates to true (.T.)

     .  Returns false (.F.) if both <lCondition1> and <lCondition2>
        evaluates to false (.F.)

     Warning!  In a departure from the Summer '87 and other dialect
     behavior, Clipper shortcuts the evaluation of .OR. operands.  This
     means that <lCondition1> and <lCondition2> are both evaluated only when
     <lCondition1> evaluates to false (.F.).  If <lCondition1> evaluates to
     true (.T.), the .OR. operation is true (.T.) and <lCondition2> is,
     therefore, not evaluated.  For backward compatibility, shortcutting can
     be suppressed by compiling with the /Z option.

 Examples

     .  This example shows .OR. results using different operands:

        ? .T. .OR. .T.            // Result: .T.   (shortcut)
        ? .T. .OR. .F.            // Result: .T.   (shortcut)
        ? .F. .OR. .T.            // Result: .T.
        ? .F. .OR. .F.            // Result: .F.

See Also: .AND. .NOT.

 

.NOT. Logical NOT

.NOT.
 Logical NOT--unary                              (Logical)

 Syntax

     ! <lCondition>
     .NOT. <lCondition>

 Type

     Logical

 Operands

     <lCondition> is a logical expression to not.

 Description

     The not (!) operator is a unary logical operator that returns the
     logical inverse of <lCondition>.

 Examples

     .  This example shows .NOT. results using different operands:

        ? ! (.T.)               // Result: .F.
        ? ! 1 > 2               // Result: .T.
        ? .NOT. 1 > 2           // Result: .T.

See Also: .AND. .OR.

 

.AND. Logical AND

.AND.
 Logical AND--binary                             (Logical)
------------------------------------------------------------------------------
 Syntax

     <lCondition1> .AND. <lCondition2>

 Type

     Logical

 Operands

     <lCondition1> and <lCondition2> are logical expressions to AND.

 Description

     The .AND. operator is a binary logical operator that executes a logical
     AND operation using the following modified Boolean rules:

     .  Returns true (.T.) if both <lCondition1> and <lCondition2>
        evaluate to true (.T.)

     .  Returns false (.F.) if either <lCondition1> and <lCondition2>
        evaluate to false (.F.)

     Warning!  In a departure from Summer '87 and other dialect behavior,
     Clipper shortcuts the evaluation of .AND. operands.  This means that
     <lCondition1> and <lCondition2> are both evaluated only when
     <lCondition1> evaluates to TRUE (.T.).  If <lCondition1> evaluates to
     FALSE (.F.), the .AND. operation is FALSE (.F.) and <lCondition2> is
     therefore not evaluated.

     For backward compatibility, shortcutting can be suppressed by compiling
     with the /Z option.

 Examples

     .  This example shows .AND. results using different operands:

        ? .T. .AND. .T.            // Result: .T.
        ? .T. .AND. .F.            // Result: .F.
        ? .F. .AND. .T.            // Result: .F.   (shortcut)
        ? .F. .AND. .F.            // Result: .F.   (shortcut)


See Also: .NOT. .OR.

 

Macro evaluation–unary

 &
 Macro evaluation--unary                         (Special)
------------------------------------------------------------------------------
 Syntax

     &<cMacroVar>[.]
     &(<cMacroExp>)

 Operands

     <cMacroVar> can be any character variable.  The period (.) is the
     macro terminator and indicates the end of the macro variable and
     distinguishes the macro variable from adjacent text in the statement.

     <cMacroExp> is a character expression enclosed in parentheses.  In
     this instance, the expression is evaluated first, and the macro
     operation is performed on the resulting character value.  This allows
     the contents of fields and array elements to be compiled and run.

 Description

     The macro operator in CA-Clipper is a special operator that allows
     runtime compilation of expressions and text substitution within strings.
     Whenever the macro operator (&) is encountered, the operand is submitted
     to a special runtime compiler (the macro compiler) that compiles
     expressions, but not statements or commands.

 Text Substitution

     Whenever a reference to a private or public macro variable, embedded in
     a character string, is encountered, the variable reference is replaced
     by the content of the macro variable.  For example,

     cMacro := "there"
     ? "Hello &cMacro"            // Result: Hello there

     If you specify a macro expression (e.g., &(cMacro1 + cMacro2)), and the
     macro variable is a local, static, field variable, or an array element,
     it is treated as literal text and not expanded.

Macro operator:nesting
 Compile and Run

     When a macro variable or expression specified within an expression is
     encountered, it is treated like an expression, with the macro symbol
     behaving as the compile and run operator.  If the macro is specified as
     a macro variable,

     cMacro := "DTOC(DATE())"
     ? &cMacro

     the macro compiler compiles, then executes the content of the macro
     variable.  The compiled code is then discarded.

     If you specify an expression enclosed in parentheses and prefaced by the
     macro operator (&),

     ? &(INDEXKEY(0))

     the expression is evaluated and the resulting character string is
     compiled and run as a macro variable.

     Using the macro operator, you can compile a character string containing
     a code block definition:

     bBlock := &("{ |exp| QOUT(exp) }")

     The run portion of the operation returns the code block as a value.  You
     may then use the code block by invoking it with the EVAL() function.
     This is especially significant in activations that involve extensive
     looping through user-defined conditions (operations that in earlier
     versions of CA-Clipper required macro expansion).  In those versions,
     the macro expression was compiled and run for each iteration of the
     loop.  With the combination of a macro expansion and a code block
     EVAL(), the compilation is performed once at compile time, and the
     EVAL() merely executes the code block each time through the loop:

     EVAL(bBlock, DATE())

     The time savings at runtime can be enormous.

 Notes

     .  Command keywords: You cannot use the macro operator (&) to
        substitute or compile command keywords.  However, you can redefine
        command keywords by modifying the command definition in Std.ch,
        overriding an existing command definition with a new definition using
        the #command directive, or redefining a command keyword using the
        #translate directive.  In any case, you may redefine a command
        keyword only at compile time, not at runtime.

     .  Command arguments: In prior versions of CA-Clipper as well as
        in other dialects, you could use macro variables as the arguments of
        commands requiring literal text values.  These included all file
        command arguments and SET commands with toggle arguments.  In these
        instances, you can now use an extended expression enclosed in
        parentheses in place of the literal argument.  For example,

        xcDatabase = "Invoices"
        USE &xcDatabase.

        can be replaced with:

        xcDatabase = "Invoices"
        USE (xcDatabase)

        It is important to use extended expressions if you are using local
        and static variables.  Generally, commands are preprocessed into
        function calls with command arguments translated into function
        arguments as valid CA-Clipper values.  File names in file commands,
        for instance, are stringified using the smart stringify result marker
        and passed as arguments to the functions that actually perform the
        desired actions.  If you specify a literal or macro value as the
        command argument, it is stringified.  If, however, the argument is an
        extended expression, it is written to the result text exactly as
        specified.  This example,

        #command RENAME <xcOld> TO <xcNew>;
        =>;
              FRENAME( <(xcOld)>, <(xcNew)> )
        //
        RENAME &xcOld TO &xcNew
        RENAME (xcOld) TO (xcNew)

        is written to the result text as this:

        FRENAME( "&xcOld", "&xcNew" )
        FRENAME( xcOld, xcNew )

        when preprocessed.  When the macro variables are stringified, the
        macro variable names are hidden in the string and not compiled.
        Later, at runtime, they are substituted into the string and passed as
        arguments to the FRENAME() function.  This precludes local and static
        macro variables since the names of the variables are not present at
        runtime to be substituted.  Public and private variables, however,
        behave as expected.

     .  Lists as arguments of commands:  The macro operator (&) will
        not fully substitute or compile a list as an argument of most
        commands.  In particular, these are commands where an argument list
        is preprocessed into an array or a code block.  Instances of this are
        arguments of the FIELDS clause and SET INDEX.  An exception is the
        SET COLOR command which preprocesses the list of colors into a single
        character string and passes it to the SETCOLOR() function.

        In any case, list arguments should always be specified as extended
        expressions with each list argument specified:

        LOCAL xcIndex := { "Ntx1", "Ntx2" }
        SET INDEX TO (xcIndex[1]), (xcIndex[2])

     .  Arrays: You can use the macro operator (&) with arrays and
        array elements.  However, because of the increased power of
        CA-Clipper arrays, you may find less need to use the macro operator
        (&) to  make variable references to arrays.  You can now assign array
        references to variables, return array references from user-defined
        functions, and nest array references within other arrays.  You may
        also create arrays by specifying literal arrays or using the ARRAY()
        function.

        You can, therefore, make references to arrays and array elements
        using both macro variables and macro expressions with the restriction
        that you cannot make the subscript references in a PRIVATE or PUBLIC
        statement.  Also, you cannot specify the macro operator (&) in a
        declaration statement, such as a LOCAL or STATIC statement.
        Attempting this will generate a fatal compiler error.

        This example references array elements using macro variables:

        cName := "aArray"
        nElements := 5
        cNameElement := "aArray[1]"
        //
        PRIVATE &cName.[nElements]      // Creates "array" with 5
                                        // elements
        &cNameElement. := 100           // Assigns 100 to element 1
        &cName.[3] := "abc"             // Assigns "abc" to element 3

        You can successfully apply a macro operator (&) to an array element
        if the reference is made using a macro expression.  A macro variable
        reference, however, will generate a runtime error.  For example, the
        following lists the values of all fields of the current record:

        USE Customer NEW
        aStruc := DBSTRUCT()
        //
        FOR nField := 1 TO LEN(aStruc)
           ? &(aStruc[nField, 1])
        NEXT

     .  Code blocks: You can apply the macro operator (&) to a macro
        variable or expression in a code block in most cases. There is a
        restriction when the macro variable or macro expression contains a
        declared variable.  A runtime error occurs if you specify a complex
        expression (an expression that contains an operator and one or more
        operands) that includes the macro operator (&) within a code block.

        This has important implications for the use of local and static
        variables in the conditional clauses of commands, since these clauses
        are blockified as they are written to the result text during
        preprocessing.  This applies to all FOR and WHILE clauses, the SET
        FILTER command, and the SET RELATION linking expression.  The general
        workaround is to gather the entire expression into a single macro
        variable then apply the macro operator (&) to the variable.

     .  Macro conditions: When using the macro operator (&) to specify
        conditional clauses of database commands such as FOR or WHILE
        clauses, there are some restrictions based on the expression's
        complexity and size:

        -  The maximum string size the macro compiler can process is 254
           characters.

        -  There is a limit to the complexity of conditions (the more
           complex, the fewer the number of conditions you can specify).

     .  Procedures and functions: You can reference procedure and
        function calls using macro variables and expressions.  With DO, the
        macro variable reference to the procedure can be all or part of the
        procedure name.  With a call to a function (built-in or user-
        defined), the macro variable reference must include the function name
        and all of its arguments.

        In CA-Clipper, because of the added facility code blocks, all
        invocations of procedures and functions using the macro operator
        should be converted to the evaluation of code blocks.  This code
        fragment

        cProc := "AcctsRpt"
        .
        .
        .
        DO &cProc

        can be replaced with:

        bProc := &( "{ || AcctsRpt() }" )
        .
        .
        .
        EVAL(bProc)

        The advantage of a code block over a macro evaluation is that the
        result of the compilation of a string containing a code block can be
        saved and, therefore, need only be compiled once.  Macro evaluations
        compile each time they are referenced.

     .  References into overlays:  You must declare procedures and
        user-defined functions that are used in macro expressions and
        variables but not referenced elsewhere as EXTERNAL, or the linker
        will not include them into the executable (.EXE) file.

     .  TEXT...ENDTEXT:  Macro variables referenced within a
        TEXT...ENDTEXT construct are expanded.  Note that a field cannot be
        expanded, so you must first assign the field value to a memory
        variable then reference the memory variable as a macro variable
        within the TEXT...ENDTEXT.  For example:

        USE Customer NEW
        myVar := Customer->CustName
        TEXT
        This is text with a macro &myVar
        ENDTEXT

     .  Nested macros:  The processing of macro variables and
        expressions in CA-Clipper permits nested macro definitions.  For
        example, after assigning a macro variable to another macro variable,
        the original macro variable can be expanded resulting in the
        expansion of the second macro variable and evaluation of its
        contents:

        cOne = "&cTwo"             // expand cTwo
        cTwo = "cThree"            // yielding "cThree"
        cThree = "hello"
        //
        ? &cOne                    // Result: "hello"

Expression Terms

Assignment :

The act of copying a new value into a variable. In Clipper language this is done with the simple assignment operators (=) and (:=), or the compound operators (+=, -=, *=, **=).

Binary Operator :

An operator that operates on two operands. For example, the addition operator.

See Also: Operator

Character Functions :

Those functions that act upon individual characters or strings of ASCII characters in the performance of their tasks.

See Also: ASCII, Function, String

Concatenate :

To combine two groups of character data together by placing them in a sequence to form a new string of characters.

See Also: Data Type

Condition :

A logical expression that determines whether an operation will take place. With database commands, a logical expression that determines what records are included in an operation. Conditions are specified as arguments of the FOR or WHILE clause.

Conversion Functions :

Generally referring to a category of functions whose purpose is to change one data type to another (e.g., to change a number or a date to a character string).

Date Functions :

Functions that operate on date values (as opposed to character, numeric or other values).

See Also: Function

Decrement :

To decrease a value by a fixed amount, usually one. In Clipper, the decrement operator (–) can be used to decrement a numeric value in a variable.

See Also: Assignment Increment

Destination :

The variable or array element to receive data in an assignment.

See Also: Assignment

Evaluate :

To execute part of a program in order to produce a value. For an expression, to execute the program code associated with the expression and return the resulting value. For the macro operator, to compile the macro string, execute the resulting program code, and return the resulting value.

See also : Expression

Expression :

A combination of constants, identifiers, operators, and functions that yield a single value when evaluated.

Increment :

To increase a value by a fixed amount, usually one. In Clipper language the increment operator (++) can be used to increment a numeric value in a variable.

List :

A list of expressions, field names, or filenames, separated by commas specified generally as command, procedure, or function arguments. Code blocks can also execute a list of expressions.

Macro :

In Clipper language, an operation that allows source code to be compiled and executed at runtime. In Clipper language, the macro symbol (&) does not perform text substitution unless embedded within a character string. Instead, it is generally treated as a unary operator that operates on a character string. The text in the character string is compiled on the fly using a special runtime compiler. The resulting code is then executed, and the value obtained is returned as the result of the macro operation.

See Also: Code Block, Unary Operator

Operand :

A value that is operated on by an operator, or the term in an expression that specifies such a value. For example, in the expression x + 5, x and 5 are operands.

See Also: Operator

Operator :

A symbol that identifies a basic operation. For example, the multiplication operator (*) denotes that two values are to be multiplied. Operators are categorized as either unary or binary, depending on whether they require one or two operands, respectively.

See Also: Binary Operator, Operand, Unary Operator

Precedence :

The stature of an operator in the hierarchy that determines the order in which expressions are evaluated. For example, the expression 5 + 2 * 3 is interpreted as 5 + (2 * 3) because the multiply operator (*) has a higher precedence than the addition operator (+).

See Also: Expression

Recursion :

The calling of a procedure by a statement in that same procedure. When a procedure calls itself it is said to recurse. A recursive call causes a new activation of the procedure. If the source code for the procedure includes a declaration of local variables, a new set of local variables is created for each activation. A private variable created by the procedure is associated with the activation in which it is created, and is visible in that activation and any lower-level activations, unless obscured by a private variable created in a lower-level activation.

See Also: Activation, Function, Private Variable, Procedure

Shortcutting :

A compiler optimization that causes expressions to be evaluated only to the extent required to determine their outcome. For example, in the expression f() .OR. g() function g need not be executed if function f returns true (.T.). Clipper language performs shortcutting on all logical operators (.OR. .AND. .NOT.).

Truncate :

To remove insignificant information from the end of an item of data. With numerics, to ignore any part of the number that falls outside of the specified precision.

Unary Operator :

An operator that operates on a single operand. For example, the .NOT. operator.

See Also: Binary Operator, Operator

Variable Terms

Argument :

Generally, a value or variable supplied in a function or procedure call, or an operand supplied to an operator. In function and procedure calls, arguments are often referred to as actual parameters.

See also : Parameter

Constant :

The representation of an actual value. For example, .T. is a logical constant, string is a character constant, 21 is a numeric constant. There are no date and memo constants.

Declaration :

A statement used by the compiler to define a variable, procedure, or function identifier. The scope of the declaration is determined by the position of the declaration statement in the source file.

See Also: Identifier, Scope

Dynamic Scoping :

A method of determining an item’s existence or visibility based on the state of a program during execution. Example: A Clipper public variable may or may not be visible within a particular function, depending on whether the variable has been created and whether a previously called function has obscured it by creating a private variable with the same name.

See Also: Lexical Scoping, Scope

Field Variable :

A variable that refers to data in a database field, as opposed to data in memory.

See Also: Local Variable, Memory Variable, Variable

Filewide Declaration :

A variable declaration statement that has the scope of the entire source file. Filewide declarations are specified before the first procedure or function declaration in a program file and the program file must be compiled with the /N option.

See Also: Scope, Storage Class

Identifier :

A name that identifies a function, procedure, variable, constant or other named entity in a source program. In Clipper language, identifiers must begin with an alphabetic character and may contain alphabetic characters, numeric characters, and the underscore character.

Initialize :

To assign a starting value to a variable. If initialization is specified as part of a declaration or variable creation statement, the value to be assigned is called an initializer.

See Also: Assignment

Lexical Scoping :

A method of determining an item’s existence, visibility, or applicability (i.e., the item’s scope) by it’s position within the text of a program.

See Also: Local Variable, Scope, Static Variable

Lexically Scoped Variable :

A variable that is only accessible in a particular section of a program, where that section is defined using simple textual rules. For example, a local variable is only accessible within the procedure that declares it.

See Also: Dynamic Scoping, Local Variable, Static Variable

Lifetime of a Variable :

The period of time during which a variable retains its assigned value. The lifetime of a variable depends on its storage class.

See Also: Scope, Visibility

Local Variable :

A variable that exists and retains its value only as long as the procedure in which it is declared is active (i.e., until the procedure returns control to a higher-level procedure). Local variables are lexically scoped; they are accessible by name only within the procedure where they are declared.

See Also: Dynamic Scoping, Lexical Scoping, Static Variable

Memory Variable :

In general, a variable that resides in memory, as opposed to a database field variable. Sometimes used specifically to refer to variables of the MEMVAR storage class (private and public variables), as opposed to static or local variables.

See Also: Field Variable, Private Variable, Public Variable, Variable

Parameter :

A identifier that receives a value or reference passed to a procedure or user-defined function. A parameter is sometimes referred to as a formal parameter.

See Also: Activation, Argument, Function, Procedure, Reference

Private Variable :

A variable of the MEMVAR storage class. Private variables are created dynamically at runtime using the PRIVATE statement, and accessible within the creating procedure and any lower-level procedures unless obscured by another private variable with the same name.

See Also: Activation, Dynamic Scoping, Function, Public Variable

Public Variable :

A variable of the MEMVAR storage class. Public variables are created dynamically at runtime using the PUBLIC statement, and are accessible from any procedure at any level unless obscured by a private variable with the same name.

See Also: Activation, Dynamic Scoping, Function, Private Variable

Reference :

A special value that refers indirectly to a variable or array. If one variable contains a reference to a second variable (achieved by passing the second variable by reference in a function or procedure call), operations on the first variable (including assignment) are passed through to the second variable. If a variable contains a reference to an array, the elements of the array can be accessed by applying a subscript to the variable.

See Also: Array Reference, Parameter

Static Variable :

A variable that exists and retains its value for the duration of execution. Static variables are lexically scoped; they are only accessible within the procedure that declares them, unless they are declared as filewide, in which case they are accessible to any procedure in the source file that contains the declaration.

See Also: Dynamic Scoping, Lexical Scoping, Local Variable

Storage Class :

Defines the two characteristics of variables: lifetime and visibility.

See Also: Lifetime, Scope, Visibility

Variable :

An area of memory that contains a stored value. Also, the source code identifier that names a variable.

See Also: Local Variable, Private Variable, Static Variable

Visibility :

The set of conditions under which a variable is accessible by name. A variable’s visibility depends on its storage class.

See Also: Dynamic Scoping, Lexical Scoping