Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.5b

Application v 5.24b

  

 

Chapter ThreeData Types and Operators (continued)

3.5 Strings Versus Characters

Character arrays and strings are very similar. Both provide means to contain and alter text. For example:

char buffer[128];

buffer = "This is my string";

 

is similar to:

string buffer;

buffer = "This is my string";

 

However, in the first case the char array is limited to 128 characters (bytes) while the string is effectively unlimited (certain functions that process strings may be size limited). Whenever a character or byte array is referenced like a string, it will be treated as a string and the default zero termination applies. When a string is stored into a character array, only the valid zero-terminated portion of the string is written to the array. Any space after that will remain altered. For example:

char mystring[10];

mystring = "abcdefghi";

mystring = "123";

 

The contents of the ‘mystring’ is actually:

"123\0efghi\0"

 

Notice the \0 are actually binary zeroes. If the array was referenced as a string, the zero is considered the end of the string. For example:

MessageBox(mystring);

 

The result would display as “123”. However, the character array can be treated as a binary buffer and used in certain operations such as file reading and writing. In addition, when placed into an object with a fixed size (particularly if passed to a non-script function or as external data), the char data type has the advantage of being a fixed area of data that can be directly adjacent to other members of the same object.