company logo

ObjectSpace :: executeExpression - Execute expression

The function allows running static inline expressions, which may consist of simple operands or complete expression definitions. When running an in line expression containing one or more statements, the expression must be enclosed in {}.

The result is returned as property handle, which allows an expression returning elementary or complex instances as well as instance collections.

When referring to persistent expressions stored in the resource database, the expression name has to be preceded by the class name the expression belongs to (scoped name).

When the expression is invalid, or an error has encountered while processing the expression, the function throws an exception.

"if (1>2) Message('true')" // in line statement

"Person::GetTotalIncome(2004)" // calling persistent expression

"{ // complete inline expression

VARIABLES

int   i = 0;

PROCESS

   while i < 100) i++;

   Message(i);

}"

Notes:

Note that all calls to stored expressions within the expression string have to be scoped:

os.executeExpression("Test::testExpression()");

Instead of calling executeExpression() it is suggested to use Property::execute():

Property(os,"Test::testExpression()",Read).execute();

Return value:  Property reference ( odaba::Property  )

A property handle refers to a (usually) opened property. Invalid properties may cause an exception.

Implementation details

  1. Execute expression
    odaba::Property ObjectSpace  :: executeExpression ( odaba::String &vExpression )

    The function executes the expression passed in vExpression. When the expression refers to persistent expressions, those have to be defined in the dictionary of the object space.

    • vExpression - OSI inline expression

      An inline expression can be passed as operation path, as operand (something like a + b) or as complete expression. As operand, an expression may contain any expression, which is allowed in a statement, but no semicolon must be appended at the end.

      Complete expressions include expression header (optional) and may include different sections in the expression body which is enclosed in { ... }.

      In contrast to class expressions, inline expressions are not defined explicitly as class expressions but passed as strings to the application at run-time.

      In order to pass no expression, an empty string ( String() ) has to be passed.

  2. to list
  3. Execute expression from resource database
    odaba::Property ObjectSpace  :: executeExpression ( odaba::ObjectSpace &cResourceObjectSpace, odaba::String &vExpression, bool bServer )

    In order to run an inline expression as passed in vExpression, which refers to persistent expressions stored in a resource database different from the dictionary, the object space (resource database) containing those expressions has to be passed in rResourceObjectSpace.

    Notes:

    The OSI function or expression will always be executed locally.

    • cResourceObjectSpace - Reference to resource object space

      The resource object space handle usually is a database handle, which is referred to as object space handle.

    • vExpression - OSI inline expression

      An inline expression can be passed as operation path, as operand (something like a + b) or as complete expression. As operand, an expression may contain any expression, which is allowed in a statement, but no semicolon must be appended at the end.

      Complete expressions include expression header (optional) and may include different sections in the expression body which is enclosed in { ... }.

      In contrast to class expressions, inline expressions are not defined explicitly as class expressions but passed as strings to the application at run-time.

      In order to pass no expression, an empty string ( String() ) has to be passed.

    • bServer - Server option
  4. to list
  5. Execute expression on server side
    odaba::Property ObjectSpace  :: executeExpression ( odaba::String &vExpression, bool bServer )

    The function executes the expression passed in vExpression. When the expression refers to persistent expressions, those have to be defined in the dictionary of the object space.

    In order to execute the expression on server side (client/server environment), true has to be passed in bServer.

    • vExpression - OSI inline expression

      An inline expression can be passed as operation path, as operand (something like a + b) or as complete expression. As operand, an expression may contain any expression, which is allowed in a statement, but no semicolon must be appended at the end.

      Complete expressions include expression header (optional) and may include different sections in the expression body which is enclosed in { ... }.

      In contrast to class expressions, inline expressions are not defined explicitly as class expressions but passed as strings to the application at run-time.

      In order to pass no expression, an empty string ( String() ) has to be passed.

    • bServer - Server option
  6. to list