String-variabelen (tekenreeksen)

From Apache OpenOffice Wiki
< NL‎ | Documentation‎ | BASIC Guide
Revision as of 15:28, 20 January 2013 by DiGro (Talk | contribs)

Jump to: navigation, search
Book.png

Tekenreeksen, samen met getallen, vormen de meest belangrijke basistypen van Apache OpenOffice BASIC. Een tekenreeks bestaat uit een reeks van opvolgende individuele tekens. De computer slaat de tekenreeksen intern op als een reeks van getallen waarbij elk nummer een specifiek teken vertegenwoordigt.

Vanuit een verzameling ASCII-tekens naar Unicode

Tekensets vergelijken tekens in een tekenreeks met een corresponderende code (getallen en tekens) in een tabel die beschrijft hoe de computer de tekenreeks moet weergeven.

De tekenset ASCII

De ASCII tekenset is een serie van codes die getallen, tekens en speciale tekens vertegenwoordigen door één byte. De ASCII-codes 0 tot en met 127 corresponderen met het alfabet en tot normale symbolen (zoals punten, haken en komma's), evenals enige speciale scherm- en printercontrole-codes. De ASCII tekenset wordt in het algemeen gebruikt als een standaardformaat voor de uitwisseling van tekstgegevens tussen computers.

Deze tekenset beschikt echter niet over een bereik van speciale tekens, gebruikt in Europa, zoals â, ä en î, evenals andere teken-opmaken, zoals het Cyrillische alfabet.

De tekenset ANSI

Microsoft baseerde zijn Windows product op de American National Standards Institute (ANSI) tekenset, welke geleidelijk werd uitgebreid met tekens die ontbreken in de ASCII tekenset.

Code Pages

The ISO 8859 character sets provide an international standard. The first 128 characters of the ISO character set correspond to the ASCII character set. The ISO standard introduces new character sets (code pages) so that more languages can be correctly displayed. However, as a result, the same character value can represent different characters in different languages.

Unicode

Unicode increases the length of a character to four bytes and combines different character sets to create a standard to depict as many of the world's languages as possible. Version 2.0 of Unicode is now supported by many programs — including Apache OpenOffice and Apache OpenOffice Basic.

String Variables

Apache OpenOffice Basic saves strings as string variables in Unicode. A string variable can store up to 65535 characters. Internally, Apache OpenOffice Basic saves the associated Unicode value for every character. The working memory needed for a string variable depends on the length of the string.

Example declaration of a string variable:

Dim Variable As String

You can also write this declaration as:

Dim Variable$
Documentation note.png VBA : When porting VBA applications, ensure that the maximum allowed string length in Apache OpenOffice Basic is observed (65535 characters).


Specification of Explicit Strings

To assign an explicit string to a string variable, enclose the string in quotation marks (").

Dim MyString As String
MyString = " This is a test"

To split a string across two lines of code, add an ampersand sign (the concatenation operator) and the underscore continuation character at the end of the first line:

Dim MyString As String
MyString =   "This string is so long that it " & _
             "has been split over two lines."

To include a quotation mark (") in a string, enter it twice at the relevant point:

Dim MyString As String
MyString = "a ""-quotation mark."    ' produces a "-quotation mark


Content on this page is licensed under the Public Documentation License (PDL).
Personal tools