String

See Also: Declaring Variables, Variable Declaration Commands, Struct, String Function, String Functions, Get_StrictEval

Purpose

Declares one or more String variables.

Syntax

To declare string variables

string {identifier} [{identifier}] {globalStringLength}

Where

To declare array variables of type String

String{dimension-list} {identifier} […{identifier}]

Where

Multi-line Strings

DataFlex supports multi-line strings by placing the @ symbol in front of the opening quote.

An example of a multi-line string::

@"The quick brown fox

jumped over the lazy dog...

3 times!"

What It Does

String declares string variables. Strings can are typically used to contain data other than dates and quantities. String data encompasses any and all printable characters in any order desired.

We recommend storing binary data in UChar arrays instead of string.

Multiple variables may be declared on one command line, with their names separated from each other by spaces.

Examples

Procedure RunTest

    String sSong sKey sTempo sLyrics

End_Procedure

In this example, local string variables sSong, sKey, sTempo and sLyrics are created inside Procedure RunTest.

Literal material which is to be moved to a string variable should be enclosed in quotation marks.

String sEquation

Move "(m *(c ^2))" to sEquation

In this example, (m *(c ^2)) is moved to string variable sEquation.

If a statement moves numbers, dates or expressions not enclosed in quotation marks to a String, the value of the variable or expression will be converted to a string and moved to the String variable.

String sEquation

Number m c

Move 8 to m

Move 4 to c

Move (m *(c ^2)) to sEquation

In this example, the value of m *(c ^2) (128) is moved to string variable sEquation.

 

String[] sStudents

This example declares 1 dynamic array variable, named sStudents, containing an undefined number of elements of type string.

String[5] sStudents

This example declares 1 static array variable, named sStudents, containing 5 of elements of type string.

String[][3] sStudents

This example creates a two-dimensional dynamic array variable named sStudents, containing an undefined number of elements of type string. Conceptually, this represents a rectangular array with an undefined number of rows, each of 3 columns.

You can declare dynamic multi-dimensional arrays where all dimensions are dynamic; these are called jagged arrays.

Notes

Move "!s" to s  // s = "4761" at runtime

Move (Character(33)+ "s") to s

String gsShort 5

Move "1234567890" to gsShort

After these commands, Variable gsShort will have contents of 12345, having truncated all characters moved to it in excess of its declared length.