DATA statement   

Purpose

Declare string constants within the source code to be read by READ$ function.

Syntax

DATA ["]item["] [[, ["]item["]] ...]

Remarks

DATA statements may only appear inside of Subs, Functions, Method, or Properties, and are visible only to the code in the procedure in which they appear.  Each procedure may therefore have its own private data.

Data may consist of virtually any text characters.  Data items may be enclosed in quotes to preserve leading/trailing spaces, which are otherwise stripped during compilation.

Restrictions

There is a limit of 64 Kilobytes and 16384 separate data items per procedure.  Previous versions of PowerBASIC ignored plain text located immediately after a quoted literal up to the next comma or end-of-line; however, this is no longer acceptable and generates an Error 477 ("Syntax error").

DATA statements cannot extend across more than one physical source code line using line continuation characters.  Special care should be used when formatting DATA statements, especially if the data is to contain underscore and/or colon characters.  The following examples highlight data items in blue:

If an underscore appears after a comma, it is treated as the start of a quoted data string, rather than a line continuation character:

' Three data items exist in this line:

DATA "Tom", "Dick", _Harry

The colon (statement separator) character, when used within unquoted string data, performs as a regular statement separator:

' Two data items and a separate statement

DATA "Tom","Dick" : Harry& = 1

However, if a colon character appears within a quoted data string, it is treated as part of the data string:

' 3 data items

DATA "Tom",Dick,":Harry& = 1"

See also

DATACOUNT, READ$, VAL

Example

DATA "Abc", Bob, "Sally", 123

DATA 456.78, "  leading space"

DATA embedded "quotes within data"