Skip to main content

Strings and arrays

Strings

It is important to know how to use the character strings because they usually plays a part in numerous situations. For example, in the following script lines, a loop allows to load the projects : D:/cartoon3.tvp, D:/cartoon4.tvp, ... ... ... D:/cartoon15.tvp, D:/cartoon16.tvp.

For number=3 to 16
NameOfTheFile="D:/cartoon"number'.tvp'
tv_loadproject NameOfTheFile
End

As shown above, you will have to use simple quotation marks ('...') or double quotation marks (''...'') in order to differentiate variables from character strings. In the example above:

  • number and NameOfTheFile are variables
  • D:/cartoon and .tvp are character strings

The variable NameOfTheFile receive the concatenation of D:/cartoon, number and .tvp In other words, the character strings d:/cartoon and .tvp, the variable number have been joined end to end in order to create the variable NameOfTheFile.

tip

It is possible to use the Concat instruction to join end to end character strings and/or variables. The following lines have the same effect:

NameOfTheFile=number'.jpg'
NameOfTheFile=Concat(number,.jpg)

If you need to use simple quotation marks ('...') or double quotation marks (''...'') in your character strings, you must surround them with the other quotation marks at your disposal, as shown in the example below:

Print ' My prefered animation program is " TVP Animation " ' // will surround the name of the software with double quotation marks.
Print " My prefered animation program is ' TVP Animation ' " // will surround the name of the software with single quotation marks.

Arrays

Like other programming languages, George can create and use arrays with one, two or more dimensions. To create an array, you only need to add parentheses or square brackets after the name of a variable. You can use either parentheses or square brackets.

For instance:

  • MyArray(i) or MyArray[i] represent the same array with one dimension.
  • MyArray(i,j) or MyArray[i,j] represent the same array with two dimensions.
  • MyArray(i,j,k) or MyArray[i,j,k] represent the same array with three dimensions. And so on ...
info

With the George language, it is not necessary to indicate or declare the dimension or the number of elements before using an array.

In the example below, an array called color with one dimension was created. It contains four elements : "Magenta", "Cyan", "Yellow" and "Black" We used a loop to display its content.

color[1]="Magenta"
color[2]="Cyan"
color[3]="Yellow"
color[4]="Black"

For i=1 To 4

tv_warn color[i] // displays each color : "Magenta", "Cyan", "Yellow"
// and "Black", in a dialog box.
End