Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.5b

Application v 5.24b

  

 

Chapter ThreeData Types and Operators

3.1 Variables and Symbols

3.1.1 Variables

A variable can be defined as a portion of memory that stores a value. The value of a variable is stored in an unspecified memory location. To refer to that value, simply refer to the variable by its identifier or name.

Variables names are a sequence of any number of digits, letters, and underscore (“_”) characters. The name cannot begin with a number. Special reserve characters, punctuation, and spaces are not permitted as part of a valid variable name. In addition, Legato keywords, such as if and else, cannot be used as variable names (for a complete list of Legato SDK definitions, see Appendix A — Legato SDK Standard Definitions). Legato variable names are case-sensitive.

Examples of valid variable names:

  a x5 Q_A CharlieBrown hWindow _cat  
  $a baño @7 _ @    

 

Examples of invalid names:

  16b 0x5 my-list if while $6  
  z,y [p] :n a.a k|l    

 

Operations (such as mathematical addition and subtraction) can be performed on variables with operators. One of the most fundamental operations is the assignment of a value to a variable, as shown below:

  i = 5; r = 16.33; n = 0x12; s = "cat"; c = 'x'    

For a more in depth discussion of operators, see Section 3.11 Operators.

3.1.2 Declaration

In Legato, variables must be declared before they can be used. In its simplest form, a declaration is two parts: the variable type and the variable name. For example:

int i;

char a[];

The first statement declares a variable named i that is of the integer type. The second declares a variable named a that is an array of character values. Initialization refers to assigning a value to a variable for the first time. All variables are set to zero or empty automatically, unlike C or C++ where uninitialized variables can contain garbage. [Often initiation and declaration can occur in the same programmatic expression:]

Variables can be declared and initialized anywhere within a script so long as they are declared and initialized before they are used. However, programmatic clarity is improved when variables are declared (and initialized as necessary) at the beginning of the script.

3.1.3 Introduction to Data Types

Every variable has a type associated with it. This type specifies the amount of memory that must be allocated to store the value. On a more practical level, it also determines what type of data can be stored in that memory location. The type of a variable is strict, which means that once it is declared, it cannot be changed.

There are many types of data. Incorporating these varying data types allows Legato to interface with external programs directly or easily read and write binary data. Also, when arrays of information are required, allowing the use of smaller types can significantly reduce memory requirements. 

The following table lists the fundamental data types available in Legato.

Keyword Description Uses/Comment
Integers:    
byte 8-bit unsigned value Typically used in buffers of data.
short 16-bit signed value Small signed integer.
word 16-bit unsigned value Used to convey unsigned data and for bitwise information.
int 32-bit signed value The default signed integer value.
dword 32-bit unsigned value Used frequently to present bitwise data.
long 64-bit signed value Used for large numbers.
qword 64-bit unsigned value Used for date/time and large numbers.
Floating-Point:    
float 64-bit floating-point Floating-point or real numbers. Note, there are certain considerations when using and comparing floating-point numbers.
real 32-bit [currently 64 bits, to be adjusted]
double 64-bit [does not exist]
Strings:    
char 8-bit A character representation of ANSI textual data.
string 8-bit array Natural array or string of characters.
wchar 16-bit Wide character for Unicode textual data.
wstring 16-bit array Natural array or string of wide characters.
Other:    
boolean 8-bit A logical representation of TRUE and FALSE, 1 and 0 respectively.
handle 32-bit A unique number that represents an abstract object, process, file, window, etc...
object A collection data and functions. [not done]
     

Some types of data pertain to lower-level computing operations, such as the type byte and other types used in bitwise operations. Other types may contain memory addresses. The type of the variable tells the interpreter how to access and manage the information the variable represents.