Access the data in the data window in the PowerScript script 01-6-22 03:50:50:50:50
At 4.0, if you want to access data in the data window in the PowerScript script, the method is only one, that is, using the SETITEM and GETITEM series functions, specify the value of a race column you want to access, this method The limit is that you can only access a value at a time. In version 5.0, PowerBuilder expands the property of the data window, making the data in the data window into one of the objects of the object, and the user can access the data window as an iconicity of the image. In this way, we have two ways to access the data.
1. The use of SETITEM and GETITEM series functions, such as:
DW_1.SETITEM (1, "Empname", "Phillips")
Ls_name = dw_1.getitemstring (1, "empname")
2. Table Delivery method, this method can specify a list, a certain line, a piece, or is a list of row columns selected by the user, and even the entire data window control, such as:
DW_1.Object.empname [1] = "phillips"
DW_1.Object.data [1,1] = "phillips"
Both methods can allow users to specify a particular data buffer, that is, if you use any way, you can access the original value before the data is modified, the value of filtered off, the value of the deleted value and the current value Wait.
In most cases, you can use any of these two ways, but these two methods are also all proficades.
If you just want to visit a value of a column of a row, the two methods are the same in the execution rate.
If you plan to use the column name of the data window instead of the value to represent a column, the column name is not known before run, or to determine the user's different inputs, then you can only use the function method, because This method can dynamically change the column name.
If you need to visit the data, it is not allowed, but it is determined to make a multi-row of multi-line columns, which will have a higher efficiency.
The expression method is the new function of PowerBuilder 5.0, although this method can make the object-oriented characteristics of the data window more obvious, the expression of the language is also more intuitive, easy to make the bystander reading the procedure of others, easy to understand, However, the grammatical form of this method is very complicated, but it is not easy to use.
In general, the form of the formula can be divided into 3 groups:
Directly specify the name of the name: If you know what you need to visit the column name, and only visit this column, you can use this method. Select a record or multiple records in this control
DWControl.Object.columnname {.buffer} {.datasource} {[startrownum {, endrownum}]}
We have introduced four buffers on the data window in the previous topic. In the syntax of this command, you can select the three buffers of Primary, Filter or Delete, default to primary; DataSource options for CURRENT Or ORIGINAL, default is CURRENT. If you select Original, the system will go to the ORIGINAL buffer area of the data window to read the data, and the original buffer is read-only, you cannot assign it. In the latter square bracket, you can specify the number of startups in this column you intend to access. If you are just a record, you can specify the line number in Startrownum; if the two parameters in square brackets are all default, then Refers to all records of this column.
E.g:
String ls_name
Ls_name = dw_1.object.name [1]
As another example:
DW_1.Object.salary [8,12] = id_salary
ID_salary is an array. If there are only four elements in it, the value of the 12th line of Salry is empty.
Select this data window control to brighten records
DWControl.Object.columnname {.primary} {. datasource} .selected
The records that are brightened in the data window is that you have used the SELECTROW function to brighten the records in this line. Obviously, the access to this feature data can only be in the Primary buffer, and the data source can still be selected as the original. If you choose the original, that is, the data you have got is to repair the data before the data library.
E.g:
String ls_name
LS_NAME = dw_1.object.name.selected
Use a value to table:
DWControl.Object.data {.buffer} {.datasource} [Startrownum, StartColnum,
Endrownum, endcolnum]
We know that in the functionality of the SETITEM and GETITEM series, the expression of the column can also be used in the name of the column name, which is also the same. If we use the value to refer to the name of the listed name, we have the same comparison, we have to change the column name to the keyword DATA, in the back surface, the parameters become four. This table-based return value will be an array, or a user object. It is necessary to pay attention, and the structural or user object you define must match the data type of these columns of the data window, no PowerBuilder will make an error. Operating manipulation of the entire record:
DWControl.Object.data {.buffer} {.datasource} {[rownum]}
This method is a special example of the previous method. If the value in ROWNUM is default, the entire data of the entire data window will indicate.
Examples of the column name and data type in the data window:
ID (Number)
Name (String)
Retired_status (Boolean)
Birth_date (date)
First, we must define a str_empdata's data structure in the knot brings. It includes four elements, types of types:
Integer, String, Boolean and Date
Exercise the following code:
STR_EMPDATA LSTR_CURRDATA []
Lstr_currdata = dw_1.object.data
The upper bound of the array in this LSTR_CurrData structure will be used as the number of rows recorded in the data window control and is completed.
We can also specify the high brightness in this control with this control.
DWControl.Object.data {.primary} {.datasource} .selected
These three forms of functionality is more than that of as compared to:
Accession
Phonetic
Access to high brightness in the control
1
a row
DWControl.Object.columnname {.buffer} {.datasource}
can
2
Multi-column
DWControl.Object.data {.buffer} {.datasource}
Cannot
3
A full number of records
DWControl.Object.data {.buffer} {.datasource}
When you use these statements, we have to pay attention to the following:
In the same way with the setITEM and GetItem series, Powerbuilder will not check the effectiveness of the columns you specify, you must check and ensure the effectiveness of the reference.
In the first method, we must pay attention to the rear of the column name, such as:
ld_salary [] = dw_1.object.emp_salary.primary
ld_salray = dw_1.object.emp_salary [5]
The above-mentioned table is all combined, but
ld_salary [] = dw_1.object.emp_salary is a non-law date.
Because DW_1.Object.emp_salary refers to the DWObject object of this EMP_SAlary column, not the data in the EMP_SALARY column. We can use dw_1.object.emp_salary to refer to the objects in the data window, such as:
Integer li_data
DWObject dwo_empsalary
DWO_EMPSALY = dw_1.object.emp_salary
For Li_CNT = 1 to 100
LI_DATA = dwo_empsalary [li_cnt]
.........
NEXT
The data type returned by this expression is an i-type, and PowerBuilder will convert the database and PowerBuilder data type according to the "compatible" principle, so if you call the overload function to use the expression method to get the data window as a parameter, It is recommended that you must use a function of forced conversion data types. E.g:
WF_OVERLOAD (REAL (dw_1.object.dept_id [1])))