Home      Downloads             Documentation      FAQ     

Documentation>ETP-Basic reference>Strings

 

Strings

With ETP-Basic, it is possible to have texts with characters strings, and that, very easily. To declare a character string, use the following syntax :

Public VariableName as String

or

Local VariableName as String

To affect a value to a string, use the same methods as for other variables. To concatenate, use the "&" operator.

Example:

Local str1 as String
Local str2 as String
Local together as String
str1 = "Hello "
str2 = "World !"
together = str1 & str2

Implicit Conversion :

The ETP-Basic compiler is able to make a conversion to string. So, you can, for example, use variables of types Integer or Long in an expression of string.

Example:

Local str as String
Local number as Integer
number = 23
str = "enemies : " & number

In this example, the variable number was declared as an Integer, but it was used in the expression that affects the str string. In fact, there is an invisible conversion.

For speed reasons, String type is reduced to 50 characters. So you can't enter more than 50 characters in a string.

Using string parts :

In ETP standard library, there are some functions for using String parts. For example, the function Left gets the characters on the left of the string. So, when you write :

str = Left("enemies",4)

The variable str contains the 4 first letters of the string "enemies", that is "enem".

The Right function looks like this one, it returns the last characters of a string (on the right).

To have a part of the string in the middle of it, you can use the function called Mid.

str = Mid("Nice weather, isn't it ?",5,7)

This line gets the part of the "Nice weather, isn't it ?" string which begins at the 5th letter with a length of 7 characters. So str contains "weather"

 

Documentation>ETP-Basic reference>Strings

     
    About ETP Contact Us