xHarbour Reference Documentation > Operator Reference xHarbour Developers Network  

( )

Execution or grouping operator.

Syntax

(<expr,...>)
<symbol>([<params,...>])
<objVar>:<symbol>([<params,...>])

Arguments

<expr,...>
One or more expressions to execute, separated with commas.
<symbol>
This is the symbolic name of a function, method or procedure to execute.
<params,...>
An optional comma separated list of parameters to pass to the called function, method or procedure
<objVar>
This is a variable holding a reference to an object value (Valtype() == "O") that should execute a method.

Description

Parentheses are used to execute functions, procedures or methods, and to group expressions and define their order of execution.

When using the parentheses as a grouping operator, all items appearing inside the parentheses must be valid expressions. The grouping operator can be nested to any depth. The nesting level influences execution order of expressions, i.e. expressions on a deeper nesting level are evaluated first while expressions with the same nesting level are evaluated from left to right.

When the parentheses are used as execution operator, expressions between the parentheses are passed as arguments to the called function, method or procedure. Multiple expressions must be separated with commas. When no expression appears within the parentheses, no argument is passed.

Info

See also:& (macro operator)
Category: Special operators , Operators
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example demonstrates different scenarios for using
// the () operator.

   PROCEDURE Main
      LOCAL x

      // changing precedence of operations
      ?  5 + 2 * 2                     // result: 9
      ? (5 + 2)* 2                     // result: 14
      ?  5 + 2 * 2 - 1                 // result: 8
      ?  5 +(2 *(2 - 1))               // result: 7

      x := "  xHarbour  "

      // one function call
      ? AllTrim( x )                   // result: "xHarbour"

      // list of function calls
      ? ( x := Date(), CDow(x) )       // result: "Wednesday"
   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe