String Operations

Raptor supports two operations on strings.  The first of these is concatenation, or "gluing together" of strings.  

 

+ (Concatenation)

 

The operator for concatenation is the plus (+) sign.  The result of concatenation is that the string expression on the right of the + is appended to the string on the left, thereby giving a new string value.  A string expression can contain multiple plus signs to glue together many strings.

 

The string expression "abc" + "def" has the value "abcdef".

 

Assuming the variable name has the value "John", then "Hello, " + name + "." has the value "Hello, John.".

 

It is possible to concatenate a string expression with a numeric expression.  In this case, the result is a string expression.  For example, "The answer is: " + count will have the value "The answer is: 7" if the value of count is 7.

 

 

Length_Of

 

Length_Of is a function that returns the length of a string expression or a one-dimensional array.  

 

Length_Of(stringVar) will return a value of 12 if stringVar has the value "Hello World!" (don't forget the space and exclamation)

Length_Of("Answer" + " is") will return a value of 9.

 

 

[ ] (Indexing)

 

A string variable is, in effect, an array of characters with some special properties and operations.  Because a string is an array, we can access the individual characters making up the string by using the array indexing notation.

 

For example, if the string variable Name has the value "John Doe", then an assignment like the following:

 

initial <- Name[1]

 

gives the variable initial the value 'J'.

 

Similarly, the assignment

 

Name[6] <- 'F'

 

changes the value of Name from "John Doe" to "John Foe".

 

 

To_Character

 

To_Character is a function that returns the ASCII character that is associated with the given numeric ASCII value.

 

To_Character(70) will return a value of 'F', since 70 is the numeric ASCII value for the F character.

 

 

To_ASCII

 

To_ASCII is a function that returns the numeric ASCII value that is associated with the given ASCII character.

 

To_ASCII('F') will return a value of 70, since 70 is the numeric ASCII value for the F character.