ImportString

Description

Inserts data into a DataWindow control, DataStore object, or graph control from tab-separated, comma-separated, or XML data in a string. The way data is arranged in the string in tab-delimited columns depends on whether the target is a DataWindow (or DataStore) or a graph, and on the type of graph.

NoteXML data XML data is not supported in this release of PocketBuilder.

For DataWindow and DataStore syntax, see the ImportString method for DataWindows in the DataWindow Reference or the online Help.

Applies to

Graph controls in windows and user objects. Does not apply to graphs within DataWindow objects, because their data comes directly from the DataWindow.

Syntax

graphname.ImportString ( { importtype}, string {, startrow {, endrow {, startcolumn } } } )

Argument

Description

graphname

The name of the graph control to which you want to copy data from the specified string.

importtype (optional)

A value of the SaveAsType enumerated datatype (PocketBuilder or PowerBuilder) or a string (Web DataWindow) specifying the format of the imported string. If no import type is specified, the imported string should contain only tab-separated text. Valid type arguments are:

  • Text! (default)

  • CSV!

  • XML!

string

A string from which you want to copy the data. The string should contain tab-separated or comma-separated columns or XML with one row per line (see Usage).

startrow (optional)

The number of the first detail row in the string that you want to copy. The default is 1.

For default XML import, if startrow is supplied, the first N (startrow -1) elements are skipped, where N is the DataWindow row size.

For template XML import, if startrow is supplied, the first (startrow -1) occurrences of the repetitive row mapping defined in the template are skipped.

endrow (optional)

The number of the last detail row in the string that you want to copy. The default is the rest of the rows.

For default XML import, if endrow is supplied, import stops when N * endrow elements have been imported, where N is the DataWindow row size.

For template XML import, if endrow is supplied, import stops after endrow occurrences of the repetitive row mapping defined in the template have been imported.

startcolumn (optional)

The number of the first column in the string that you want to copy. The default is 1.

For default XML import, if startcolumn is supplied, import skips the first (startcolumn - 1) elements in each row.

This argument has no effect on template XML import.

Returns

Returns the number of data points that were imported if it succeeds and one of the following negative integers if an error occurs:

If any argument’s value is null, ImportString returns null. If the optional importtype argument is specified and is not a valid type, ImportString returns -3.

Usage

For graph controls, ImportString only uses three columns on each line and ignores other columns. The three columns must contain information that depends on the type of graph:

You can add data to more than one series by specifying different series names in the first column.

Examples

Example 1

These statements copy the data from the string ls_Text starting with row 2 column 3 and ending with row 30 column 5 to the graph gr_employee:

string ls_Text

ls_Text = . . .

gr_employee.ImportString(ls_Text, 2, 30, 3)

Example 2

The following script stores data for two series in the string ls_gr and imports the data into the graph gr_custbalance. The categories in the data are A, B, and C:

string ls_gr


ls_gr = "series1~tA~t12~r~n"

ls_gr = ls_gr + "series1~tB~t13~r~n"

ls_gr = ls_gr + "series1~tC~t14~r~n"

ls_gr = ls_gr + "series2~tA~t15~r~n"

ls_gr = ls_gr + "series2~tB~t14~r~n"

ls_gr = ls_gr + "series2~tC~t12.5~r~n"


gr_custbalance.ImportString(ls_gr, 1)

See also