String: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
Line 37: Line 37:
== Limitations ==
== Limitations ==


Since ArmA strings seem not to have any limitation in length.
Since '''ArmA''' strings seem not to have any limitation in length.


In OFP, strings of any lenght (tested to 270,000) can be declared, although using a string above 2056 characters in length with some commands may result in a crash.
In '''OFP v1.96''', manipulating and using strings above 2056 characters in length may crash the game.


[[Category: Data Types]]
[[Category: Data Types]]

Revision as of 12:29, 31 January 2007

A string is the variable type that can contain text.

Description

A string may consist of any number of ASCII characters and is enclosed by single-quotes (only in ArmA) or double-quotes. In OFP, strings could alternatively also be written enclosed by curled braces, which are reserved for Code in ArmA.

Examples (OFP):

_string = "here is my string"
_string2 = {It may contain a lot of characters #@$}

Examples (ArmA):

_string = "here is my string"
_string2 = 'It may contain a lot of characters #@$'

If you want to include double quotes (") in strings enclosed by double quotes, the inside double quotes have to be written twice.

_string = "my string ""with"" quotes"
_string2 = 'my other string "with" quotes'

Operators

The only basic operator to be used on strings is "plus". You can use "plus" to concatenate two strings.

_string = "Hello " + "world"

Commands

You can convert any type to a string using the command format. You can also use that command to build together a string out of different elements. See the documentation of format for a closer description.

_string = format ["%1", ["my","array","of","strings"]]
hint _string

=> ["my","array","of","strings"]

Limitations

Since ArmA strings seem not to have any limitation in length.

In OFP v1.96, manipulating and using strings above 2056 characters in length may crash the game.