Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.5b

Application v 5.24b

  

 

Chapter TwoLanguage Overview (continued)

2.2 Data

2.2.1 Data Used in Programming

As shown in the previous examples, data must be temporarily stored to allow a script to make decisions, output results, make queries, and so forth. The programmer decides what type of data is being stored and its availability. As in most programming languages, once the program is stopped, the variable(s) are forever gone. Therefore, anything that must be kept should be written to a location that persists, like a file, database, variable storage, registry or a settings area. Variables are covered in detail in Chapter Three — Data Types and Operators.

Data within a program can take many forms ranging from simple numbers to complex arrays of information in the form of rows and columns or even cubes. Some programming languages are said to be “strictly type cast” or “loosely type cast”, that is, data in operations must match very precisely or in the latter case, loosely with certain allowances. There are pros and cons to both types and each may be better suited to a particular operating environment and programming language.

Legato is moderately strict in its type casting. It is expected that the developer knows the type of data to be stored and used but the language is a little forgiving in how it is used. The reason for this is two-fold. First, when variable types are well defined and somewhat strict, objects can be constructed in very efficient arrays where not a lot of space is wasted. Second, it is difficult to interface with external programs or the host application if the data types are not strict. For example, if the host application or Windows expects memory to be organized in a particular manner, a loosely typed language requires the programmer to arrange the data in a specific format, a process than can be arduous. This is also true when reading and writing binary files. By being able to declare a variable as an 8, 16, 32, or 64 bit integer value or a string that is exactly 128 characters, it affords precise data reading and writing. On the other hand, it means the programmer must understand that declaring a byte variable means that it has a limit of -128 to +127 as an integer.

To further complicate matters, data within a multiple word, double or quad word (16, 32 and 64-bits) can be arranging as least significant bytes to most or vice versa. This is commonly known as “big-endian” or “little-endian”. Legato runs on Windows, specifically Intel x86, which is little-endian.

In the loose environment, a programmer can say $a = 12;. Is $a an integer or a float? Will there be minor differences during mathematical operations, and if so, how are they processed? If data must be passed to a foreign application, what will it look like? The binary representations of the integer 12 and the real 12.0 are considerably different. For certain applications this is not an issue. For what Legato is designed to do, it was determined that placing a little burden on the developer was worth reaching a higher level of precision.

2.2.2 Types and Sources of Data

Data can generally be thought to come from the following sources:

Internal to the Script – These data are stored in Legato variables and exist throughout the execution of the script according to each variable’s scope. They exist in computer memory, and their values are accessed and altered through Legato functions and operations.

Files – Data can be stored in any number of formats with files. The files can be located on the local file system, on network servers or in the Virtual File Cloud (VFC).

Databases – Legato offers means to access data stored in databases through queries, such as SQL queries.

Registry and Settings – Data is often located with system settings. These data typically affect how the operating system and programs installed on it function. This data is usually specific to the user and invisible to the user.

Application Data – Data from the application, such as the contents of an edit window, can be seamlessly passed to Legato scripts. Information altered or created by Legato can also be sent back to the application for display, further editing, or other user-driven or application-driven processes.

2.2.3 Sharing Data

Within Legato, the scope of variables dictates how their information can be shared. Variables that are global are available throughout the script. However, many variables that are defined locally must be passed to other functions. This means the data is handed to the function in a manner dictated by that function’s parameter list. All variables are passed by value, not by reference, unless otherwise specified. This means that functions cannot alter the data contained within the variable.

Legato variables are not automatically available to other scripts, to the application, or to other external programs. However, the programmer can interface with these programs by passing Legato variables into external functions; again, the format of these variables must strictly match the parameter list of the external function. Similarly, external functions can pass data to Legato via Legato function calls.

2.2.4 Fundamental Data Types

Like most programming languages, Legato adheres to fundamental data types as outlined below:

Numeric types – Numeric types represent numbers. There are two types: integers, which contain whole numbers or counting numbers, and floating-point numbers, which represent real numbers that have fractional parts. Integers can be defined from 8 to 64 bits in signed and unsigned modes.

Text types – Text types represent textual information. Legato supports text strings (multiple characters contained in a single variable) and character (a singular or an array of character entities) data types. Wide or Unicode strings are only partially supported in Version 1.1a and later.

Boolean – Boolean types are employed in logical comparisons. They can either be TRUE or FALSE. Boolean types can be related to other data types where TRUE is any value that is non-zero and FALSE is zero.

Handle – The handle type is a method of referencing an abstract item such as an object or a window. In Legato, handles (and the items that they reference) are either managed by the script engine or unmanaged. From a binary standpoint, handles are 32-bit unsigned values (dword).

Cluster – The cluster types include objects and other abstract items that can in and of themselves contain other data types and other clusters.

Data types are covered in greater detail in Section 3.3.

2.2.5 Arrays, Lists and Tables

Many of the data types can also be referenced as array with up to 3 dimensions. Conventionally, a single-dimension array is a list, a two-dimension array is a table and a three dimension array is a cube.

Strings are actually treated as an array of characters and can be thought of as extra dimension.