FANDOM


This article is part of the Getting Started series

A character string is a variable or constant that contains one or more printable or unprintable characters. A string usually contains only characters from the ASCII Table. Strings' contents is always surrounded by two apostrophes ('), for example:

s:='abc';

In fact, strings are used very often, especially when writing messages on the screen:

write ('Hello world!');
write ('The sum is: ',s);

The text between the apostrophes is in fact a character string.

The advantages and the disadvantages of the character string Edit

The character string is more simple to work with, to "play" with and to manage. Although character strings can not be supposed to addition, substraction, multiplication or division, even if they contain numbers. The plus (+) sign will concatenate two strings, while any other signs will cause an error. For example:

a:='abc';
b:='XYZ';
c:=a+b; {c will be 'abcXYZ'}

Note that the strings are case-sensitive but there is a method to make all the characters uppercase, using the Upcase function.

A character in a string can be retrieved by telling the position of it, just like in vectors. For example, if s:='abc', then s[1] is a, s[2] is b, s[3] is c.

Str and ValEdit

The str and the val function convert a number into a string and back.

a:=123;
str (a,s); {converts the a number variable into a string and places it in the s string variable}
val (s,a,er); {converts the s string variable into the a number variable and
if there is an error, er will contain the position in the string 
where the error occured}

For more information on these functions and other functions also, see String operations.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.