Obtains data from a control.
To obtain |
Use |
---|---|
The value of a data point in a series in a graph |
|
The unformatted data from an EditMask control |
|
Data from an OLE server |
Gets the value of a data point in a series in a graph.
Graph controls in windows and user objects, and graphs in DataWindow controls
controlname.GetData ( { graphcontrol, } seriesnumber, datapoint {, datatype } )
Argument |
Description |
---|---|
controlname |
The name of the graph from which you want data, or the name of the DataWindow control containing the graph. |
graphcontrol (DataWindow control only) |
(Optional) A string whose value is the name of the graph from which you want the data when controlname is a DataWindow. |
seriesnumber |
The number that identifies the series from which you want data. |
datapoint |
The number of the data point for which you want the value. |
datatype (scatter graph only) |
(Optional) A value of the grDataType enumerated datatype specifying whether you want the x or y value of the data point in a scatter graph. Values are:
|
Double. Returns the value of the data in datapoint if it succeeds and 0 if an error occurs. If any argument’s value is null, GetData returns null.
You can use GetData only for graphs whose values axis is numeric. For graphs with other types of values axes, use the GetDataValue function instead.
These statements obtain the data value of data point 3 in the series named Costs in the graph gr_computers in the DataWindow control dw_equipment:
integer SeriesNbr
double data_value
// Get the number of the series.
SeriesNbr = &
dw_equipment.FindSeries("gr_computers", "Costs")
data_value = dw_equipment.GetData( &
"gr_computers" , SeriesNbr, 3)
These statements obtain the data value of the data point under the mouse pointer in the graph gr_prod_data and store it in data_value:
integer SeriesNbr, ItemNbr
double data_value
grObjectType MouseHit
MouseHit = &
gr_prod_data.ObjectAtPointer(SeriesNbr, ItemNbr)
IF MouseHit = TypeSeries! THEN
data_value = &
gr_prod_data.GetData(SeriesNbr, ItemNbr)
END IF
These statements obtain the x value of the data point in the scatter graph gr_sales_yr and store it in data_value:
integer SeriesNbr, ItemNbr
double data_value
gr_product_data.ObjectAtPointer(SeriesNbr, ItemNbr)
data_value = &
gr_sales_yr.GetData(SeriesNbr, ItemNbr, xValue!)
Gets the unformatted text from an EditMask control.
EditMask controls
editmaskname.GetData ( datavariable )
Argument |
Description |
---|---|
editmaskname |
The name of the EditMask control containing the data. |
datavariable |
A variable to which GetData will assign the unformatted data in the EditMask control. The datatype of datavariable must match the datatype of the EditMask control, which you select in the Window painter. Available datatypes are date, DateTime, decimal, double, string, and time. |
Integer. Returns 1 if it succeeds and -1 if an error occurs. If any argument’s value is null, GetData returns null.
You can find out the datatype of an EditMask control by looking at its MaskDataType property, which holds a value of the MaskDataType enumerated datatype.
This example gets data of datatype date from the EditMask control em_date. Formatting characters for the date are ignored. The String function converts the date to a string so it can be assigned to the SingleLineEdit sle_date:
date d
em_date.GetData(d)
sle_date.Text = String(d, "mm-dd-yy")
This example gets string data from the EditMask control em_string and assigns the result to sle_string. Characters in the edit mask are ignored:
string s
em_string.GetData(s)
sle_string.Text = s
Gets data from the OLE server associated with an OLE control using Uniform Data Transfer.
OLE controls and OLE custom controls
olename.GetData ( clipboardformat, data )
Argument |
Description |
---|---|
olename |
The name of the OLE or custom control containing the object you want to populate with data |
clipboardformat |
The format for the data. You can specify a standard format with a value of the ClipboardFormat enumerated datatype. You can specify a nonstandard format as a string. Values for clipboardformat are:
If clipboardformat is an empty string or a null value, GetData uses the format ClipFormatText! |
data |
A string or blob variable that will contain the data from the OLE server. If the data you want to get is not appropriate for a string, you must use a blob variable. |
Integer. Returns 0 if it succeeds and -1 if an error occurs.
GetData will return an error if you specify a clipboard format that the OLE server does not support. To find out what formats it supports, see the documentation for the OLE server.
GetData operates via Uniform Data Transfer, a mechanism defined by Microsoft for exchanging data with container applications. PowerBuilder enables data transfer via a global handle. The OLE server must also support data transfer via a global handle. If it does not, you cannot transfer data to or from that server.
After the user has activated a Microsoft Word document and edited its contents, this example gets the contents from the OLE control ole_word6 and stores the contents in the string ls_oledata. The contents of the string are then displayed in the MultiLineEdit mle_text:
string ls_oledata
integer li_rtn
li_rtn = ole_word6.GetData( &
ClipFormatText!, ls_oledata)
mle_text.Text = ls_oledata
One OLE control displays a Microsoft Word document containing a table of data. This example gets the data in the report and assigns it to a graph in a second OLE control. Microsoft Graph in the second control interprets the first row in the table as headings, and subsequent rows as categories or series, depending on the settings on the Data menu:
string ls_data
integer li_rtn
li_rtn = ole_word.GetData(ClipFormatText!, ls_data)
IF li_rtn <> 1 THEN RETURN
li_rtn = ole_graph.SetData(ClipFormatText!, ls_data)