Main concepts

Introduction

The same high-level concepts that define programming languages also apply to Linx. Concepts like Functions, Types, Services and Events are all there, just packaged differently to make them easier to define and use. If you ever get stuck in Linx just think of what the programmatic answer will be and you’re likely to find something similar or be able to construct it from functionality in Plugins.

Linx Programming equivalents
Solution
Container for one or more projects.
Solution e.g. Visual Studio solution.
Project
Container for related functionality.
Project e.g. Java project.
Process, Function
Container for instructions to perform a specific task.
Function, Procedure, Subroutine.
Type
Define structure of data.
Data type e.g. string, integer, structure.
Service
Code that runs in the background.
Daemon, Windows Service.
Event
Process triggered by a Service.
Event Handler.
Plugin
Container for pre-built functions, types and services.
Package e.g. Nuget or npm package.
Server
Host for Linx Solutions.
Server, Host e.g. Apache and IIS hosts web apps.

Each of these concepts are covered in this guide. Once you master them you’ll be able to create complex apps from the reusable components that come with Plugins or the pieces you build yourself.

Every chapter builds on the knowledge gained from the previous chapters. We recommend that you read these chapters in order.

Plugins

Functionality is added via Plugins. They contain pre-built Functions, Types and Services. Think of them as Nuget or npm packages that can be installed and used in your Linx Solution.

The Linx and Utilities plugins are installed by default and contain all the basic types and functions. Click on the ADD PLUGINS button to see all available plugins.

plugins panel screenshot

Plugins contain simple types like string or integer, generic functions like CallRESTService, complex services like RESTHost and specialized functionality like the AWS APIs.

Processes

Defining a Process

A Process is a Function. In fact we are going to rename it to Function in some future version but at the moment it’s called a Process. Here is a C# function compared to the Linx version:

processes diagram

  1. The Process definition lives in the Solution Explorer.
  2. Its Input property defines the parameters.
  3. Its Output property defines the result.
  4. The central working area contains the body of the function.
  5. Linx does not have an explicit ‘return’. When the Process finishes the Output is returned.

Setting the result of a Process

  1. The SetValue function comes from the Linx Plugin.
  2. The Target property is set to $.Output.result. Select it from the dropdown. The Source property is set to an expression that adds the two numbers from $.Input. Use the Expression Editor in the dropdown to build the expression. The ‘=’ in front of the values in Target and Source indicates that these values are expressions and not literal values.

Using SetValue

Click DEBUG to run the Process and see the result.

Calling a Process

Calling a Process is the same as one function calling another in programming.

process parameters

  1. Processes are dragged onto the body of another Process to call them.
  2. Parameters of the called Process are visible as Properties.

Click DEBUG to run the Process and see the result.

Using the result of a Process

The body of a Process works exactly like the body of a programming function. Statements and expressions are added in a top down fashion and can refer to items in its scope. When we add another AddNumbers process to the body of UseAddNumbers we can set its parameters to the result of the first AddNumbers:

process results

Click DEBUG to run the Process and see the result.

Types

Simple Types

Linx plugin contains simple types Boolean, Byte, DateTime, Decimal, Double, Integer and String. Use a Type to create a variable in a Process by

  1. Dragging it onto the body of the Process and
  2. Setting the Value property.

simple types

Complex Types

Complex types have properties that can in turn be simple or complex. Plugins may provide their own complex types for use as variables in Processes. To create your own complex type

  1. Click Custom Type
  2. Add properties

complex types

To use the custom type as a variable

  1. Drag it onto the Process body and
  2. Set property values by using the Fields Editor in the dropdown or clicking the editor icon.

using custom types

Lists

A list can contain any type. To use one

  1. Drag List from the Linx plugin onto the Process body.
  2. Set the Type property. It defaults to String.
  3. Add items in the editor by selecting the List Editor from the dropdown or clicking the editor icon.
  4. Other functions to manipulate the list are available in the Linx plugin.

List type

Properties and Expressions

Properties

Processes, Functions, Types and Services have properties that are visible in the Properties tab. Properties can be static or dynamic. Static properties are set at design time and cannot be changed at runtime. Dynamic properties can be changed at runtime by using an Expression.

Property values are usually represented in a text format that fits the type of property. Some examples are

  • Complex types are saved as JSON e.g. a Property of type Person might have a value of ‘{"Name":"John", "Surname":"Smith"}’.
  • Lists are saved as JSON e.g. ‘[“abc”,”def”]’.
  • Database functions have a ‘Connection string’ property that are saved as is e.g. ‘Data Source=.\dbServer;Initial Catalog=mydb…’.
  • Expressions are saved as ‘=expression’.
Some of the formats have an editor that appears as an icon next to the value or is available in the dropdown as shown in the next section.

Expressions

Expressions are recognizable by the ‘=’ in front of the value in the Property tab e.g. a property value of ‘1+1’ will result in ‘1+1’ at runtime while ‘=1+1’ will result in ‘2’. It works like Excel except that expressions are only resolved at runtime.

Selecting a value in scope will automatically insert an expression referencing that value. There is also an Expression Editor available in the dropdown of dynamic property values where more complex expressions can be constructed.

expressions

Control flow and scope

Control flow

Control flow statements are implemented as functions. The Linx plugin contains DoWhile, ForEach, IfElse and TryCatch. They work exactly like their programming counterparts.

ForEach loops through any list and exposes each item in an execution path. To try it:

  1. Create a list and call it Names.
  2. Drag a ForEach from the Linx plugin.
  3. Set the List property to Names (using the dropdown).

ForEach Function

The ForEach shows an execution path called Loop. This path will be executed once for each item in the List. To see it working:

  1. Add a couple of items to Names.
  2. Add the File plugin.
  3. Drag the TextFileWrite function into the box below Loop.
  4. Set the File path property.
  5. Set the Contents property to ForEach.Loop by selecting it from the dropdown.

ForEach Loop

Click DEBUG to run the Process and see the result.

DoWhile and IfElse use expressions to control the program flow. To try DoWhile:

  1. Add an Integer to the Process and name it Counter.
  2. Add a DoWhile and set its Condition property to Counter < 5. Use the Expression Editor in the dropdown to make this easier. DoWhile will keep on executing while the Condition is true.
  3. Add a SetValue to the Loop and set its properties to add 1 to Counter each time it executes.

DoWhile Function

Click DEBUG to run the Process and see the result.

Scope

Scope in Linx Processes works the same as in programming. Data is in scope if it is an ancestor in the execution tree.

Function scope

Services

Linx Services are similar in concept to Windows Services or Daemons. It is code that is loaded and kept running by the Linx Server and communicates with Linx through Events. The steps to implement a Service are:

  1. Use Linx Designer to develop a solution which contains a Linx Service and reacts to its Events. At this point you have a design but nothing is running.
  2. Deploy the solution to a Linx Server and start the Linx Service. Now the Service is loaded by the Linx Server and triggering events which in turn does whatever you told it to do.

Examples of Linx Services are

  • Timer. Fires a TimerEvent at specified times.
  • RESTHost. Fires events when its endpoints are called by clients.

Using a Linx Service

To illustrate how to use a Service we’ll use a Timer Service to write to a file every 10 seconds.

  1. Drag the Timer Service from the Utilities plugin onto your project.
  2. Set the “Run every” property to 10 seconds.
  3. Install the File plugin and add the TextFileWrite function to the TimerEvent.
  4. Set the File path property.
  5. Set the Contents property to $.Input.Data. It is the data that the Event passes to Linx. In this case the date and time that the event fires.

services

Select Timer and click DEBUG to start the Timer Service, see the events firing and debug the events. You can also select the TimerEvent and click DEBUG to run it in which case it will work just like debugging a Process.

Server

Linx Server hosts Linx Solutions and runs all the services within the solution. Solutions are deployed to Linx Server from within Linx Designer or uploaded from the Linx Server management console. Linx Server manages

  1. Linx Applications and their Services
  2. Users
  3. Configuration
  4. Logging
  5. Metrics
  6. Updates
  7. Resources

The Linx Server management console is a web application and looks like this:

Linx Server