2017 June Release

ScopesPermanent link for this heading

A scope is similar to a container holding a value that is accessible during the evaluation of an expression. The following distinct scopes are available to you when an expression is evaluated:

  • local scope, which is accessed using the operator :>
  • global scope, which is accessed using the operator ::
  • temporary scope, which is accessed using the operator @

You can use the keyword this along with the corresponding operator to access the value of a scope (e.g. :>this yields the value of the local scope, and ::this the value of the global scope). However, in most cases the keyword this can be omitted. When accessing the local scope, you can also omit the operator :> in most cases.

Note: Inside the selection operator [] for selecting values of lists or compound properties, the :> operator is required to access the local scope.

The keyword declare is used to declare an identifier. The Fabasoft app.ducx compiler automatically generates identifier declarations for use case parameters to allow access to parameters over the local scope when implementing a use case in app.ducx expression language.

For the following example, assume that the local scope this contains an instance of object class APPDUCXSAMPLE@200.200:Order, and that the temporary variable @customer contains an instance of object class FSCFOLIO@1.1001:ContactPerson. APPDUCXSAMPLE@200.200:customerorders is an object list pointing to instances of object class APPDUCXSAMPLE@200.200:Order. Within the square brackets put after APPDUCXSAMPLE@200.200:customerorders, this has a different meaning as it refers to each instance stored in the object list, and not to the local scope.

Example

ContactPerson @customer;

// Returns a STRINGLIST containing the names of all orders in property
//
APPDUCXSAMPLE@200.200:customerorders
@customer.customerorders[objname];

// Returns an OBJECTLIST containing the orders whose name is identical to
// the name of the order in the local scope

@customer.customerorders[objname == :>objname];


In the following example, two strings, isbn and title, are declared in the local scope this. The temporary variable @publication is initialized with a compound structure consisting of two string properties, isbn and title that in turn are initialized using the two strings isbn and title from the local scope.

Note: Within the scope of the curly braces, this refers to the compound structure itself. To access the local scope, the :> operator must be used.

Example

string isbn = "000-0-00000-000-0";
string title = "An Introduction to Fabasoft app.ducx";

@publication = { isbn = :>isbn, title = :>title };

For better readability, the "JavaScript" notation should be used. In this notation, the right side of the assignment is always the local scope.

Example

string isbn = "000-0-00000-000-0";
string title = "An Introduction to Fabasoft app.ducx";

@publication = { isbn : isbn, title : title };

The temporary scope @this is only used for storing temporary values during the evaluation of an expression. Local scope this and global scope ::this are similar to parameters, and can be populated with any valid Fabasoft Folio values when the Evaluate method is called for evaluating an expression.

The scopes cannot be changed while an expression is evaluated. However, you can add or modify dictionary entries if a scope contains a dictionary.