Hello from Prognoz!

Fore: What it is, and how to use it

14.12.15 Philipp Ponomarev
36980 0
Òàáëèöà áàçû äàííûõ

In the Prognoz Platform, we use the Fore programming language. In this article, we’ll highlight Fore from different perspectives;
we’ll describe its externals and explain how to use it. In articles to follow, we’ll tell you how Fore interacts with external objects and the Fore.Net language.

The need for Fore

Before getting into Fore’s capabilities, I’d like to discuss the background of developing the Fore language.

The Prognoz Platform combines cutting-edge data warehousing, visual data delivery, OLAP, reporting, business process modeling, and forecasting tools. In all-in-one systems like the Prognoz Platform, a change in the state of any component might cause an event affecting other components. Therefore, providing for the adaptability and configurability of the various system components to such changes is critical. For that purpose, we began to develop our own high-level programming language to integrate the different parts of the platform.

Now, let’s take a closer look at Fore.

Fore internals

At first glance, Fore seems sophisticated, but it’s quite similar to other widely used programming languages. As an object-oriented language, Fore enables users to write their own classes and interfaces. Designed to inherit all traits of high-level programming languages, Fore can be easily used by the developer for writing code.

Fore architecture

To gain deeper insight into Fore’s traits, let’s consider the concept of an assembly. In Fore, an assembly is a container for units, forms, and resources capable of creating folders; a unit in Fore is a compiled and executable file that contains code. The only limitation is that an assembly may not contain another assembly. The assembly can have references to system assemblies and repository assemblies. A Fore assembly can work with other assemblies; it can use public classes, constants, interfaces, and so on. You just need to connect any assembly that you want to use to the desired assembly. The Prognoz Platform also has system assemblies available to connect to.

The architecture of Fore is outlined in the figure below.01-figure

System assemblies can be easily connected via development environment, which can be also used to connect repository assemblies (see the figure below).

02-assemblies

Fore-a high-level programming language

As an object-oriented high-level programming language, Fore enjoys numerous benefits. Because it’s object-oriented in nature, Fore offers features such as encapsulation, inheritance, and polymorphism. It comes with interfaces, classes, objects, their inheritances, overrides, and so on. Memory allocation is like in C#, where the programmer doesn’t need to know how memory works; a garbage collector will reclaim the unused memory and hunt down memory leaks. This significantly simplifies the development process.

Want to see Fore’s object orientation in more detail? Let’s create a simple example with classes and interfaces to demonstrate its capabilities. Our form looks like this:

03-calculate

Let’s describe the interface with a function to transform two integers into a string:

04-code-1

Create two classes that implement this interface. One of them will return the sum string, and the other will return the difference string:

05-code-2

Specify the desired interface type variable in the class form:

06-code-3

For Button 1, specify the sum class, and for Button 2, the difference class:

07-code-4

Click Button 3 to display the results of the interface function:

08-code-5

Make sure everything works correctly:

09-correct

Assembly updates, collaborative development, and security

We should not overlook aspects that are critical for the end user, like security, multiuser development, and updates. When it comes to updates, the user can create a PEF file that will be later used to update an assembly in other repositories. This enables the user to update the behavior of other repositories without any manual updates. As a result, in the target repository, the customer can use a newly developed application version that has been debugged in a different repository.

Moreover, the Prognoz Platform provides multiuser access to developed applications through the use of a version control system (VCS).

It also supports user and user group settings, including user privileges. A policy editor, mandatory access, and other security settings are provided in the Security Manager. We will explore VCS, the Security Manager, and limitations of the use of Prognoz Platform objects in more detail in a future article specifically dedicated to this topic.

Fore everywhere

Let’s move on to another important point: Fore expressions that are used throughout the platform. Below, we have provided some examples illustrating how Fore and Fore expressions are used in the platform. Let’s start with reporting and go from there.

Reporting

Fore is widely used in regular reports, including in events, expressions in cells, hyperlinks, formula areas, filtering conditions, calculable elements of dimensions, and many other ways. We’ll consider the first three of them.

Events

You can easily connect a Fore assembly to a report to describe actions for different events. The Prognoz Platform generates the required code:

10-events

To make sure that everything works correctly, connect the Ui system assembly in references and insert the following code in the created Fore unit:

11-code-6

Now, when browsing this report, you see the following:

12-hello

Expressions in formula cells

Fore is used to call external functions, while various arithmetical operators and cast operators are implemented directly in Fore.

13-cells

So, the text in the formula box after the equals sign is parsed, compiled, and executed thanks to Fore expressions.

Hyperlinks

Let’s connect a Fore unit that we’ve created beforehand to a regular report:

14-links

15-link2

Let’s write a global procedure in the unit with the connected Ui assembly.

16-code-7

Perform the following actions for the regular report cell:

17-report-cell

Now, click this hyperlink to perform the Fore function as illustrated in the figure below:

18-hlink

Expressions

Let’s consider a number of examples illustrating some expressions used in the Prognoz Platform. We’ll start from a simple procedure of data import from a file:

19-data-import

Specify the desired file name, and click Next. The following window appears:

20-data-import

Since we are interested in a calculable field, let’s add it. The standard Expression Editor window appears:

21-appears

In the Expression Editor, specify the desired expression for the new calculable field depending on other data fields. Fore is used to parse this expression. If the expression is correct, Fore is then used to compile and execute the expression. In this simple example, you can see the use of the Substring function, the cast operator, and the division operator.

Make sure that the expression works correctly:

22-correct

All expression editors in the platform are used for specifying Fore expressions.

We’ve seen how it works for data import, so now let’s look at how it’s used for modeling. Let’s take a ready-made model containing close-to-reality data in order to save time. Open the following model:

23-model

Your eyes are probably swimming in superfluous settings, so let’s try to narrow down the options. Right now, out of all the settings, we need the specification. Click Open in Editor to open it in the Expression Editor. This means that the specification is a Fore expression.

24-bindings

Also, you can specify any expression you like in the tabular dictionary edit wizard. To do so, click More Settings, and go to Block Bindings:

25-bindings2

Double-click the desired expression to edit it in the Expression Editor.

Bye for now

In the next article, we’ll tell you how Fore interacts with external objects, including COM and Fore.NET.

This blog post is an English translation of an original text authored by Philipp Ponomarev

Comment
0