PB function library-common datawindow Functions

Source: Internet
Author: User
Tags dbase rowcount

1. Insert a record: dw_1.insertrow (cur_row) Where dw_1 is the datawindow Control name, cur_row is a specific row number, and a new row is inserted before this row.

For example, dw_1.insertrow (4) indicates that an empty record will be inserted before row 4th. This function has a return value, which is the row number of the new inserted record.

2. delete a record: dw_1.deleterow (del_row) Where dw_1 is the datawindow Control name and del_row is a specific row and this row is deleted. This function has a return value. If deletion is successful, 1 is returned. If an error is returned,-1 is returned.

For example, dw_1.deleterow (23) deletes 23rd records.

3. Return the row number of the current row: dw_1.getrow () Where dw_1 is the datawindow Control name. Note: The current row is not necessarily displayed on the screen. For example, if you click the cell in 12 columns of rows 5th and drag the scroll bar, lines 23rd to 45 are displayed on the current screen, and the row is still 5th, unless the user clicks another line.

4. retrieve the data of a cell lattice: dw_1.object.col [rownum] Where dw_1 is the datawindow Control name,

Object is fixed, Col is the column name, And rownum is the row number.

For example, you need to extract the value of column 34th named xm and put it in a string variable ls_name. The statement is as follows:

String ls_name defines a string variable ls_name

Ls_name = dw_1.object.xm [34] extracts the value from the XM column in the row 34th and puts it in the ls_name variable.

To assign a value to a cell lattice, use the following method:

For example, you need to assign the value of 45 lines of XM columns to "Zhang San".

Dw_1.object.xm [45] = "James"

5. filter data: dw_1.setfilter (ls_tj) Where dw_1 is the datawindow Control name. ls_tj is the filter condition string.

For example, if a column name in a data window object is ID, you need to filter data with ID> 5 and ID <12

Dw_1.setfilter ("ID> 5 and IC <12"); set the filter condition "id> 5 and IC <12"

Dw_1.filter (); Filter

6. Sort data: dw_1.setsort (ls_sort) Where dw_1 is the datawindow Control name. ls_sort is the sort condition string.

For example, if the name of a column in a data window object is NL, the column needs to be sorted by NL in ascending order.

Dw_1.setsort ("nl asc"); set the sorting condition "nl asc" (ASC in ascending order and desc in descending order)

Dw_1.sort (); Filter

7. Number of returned records: dw_1.rowcount () Where dw_1 is the datawindow Control name.

For example, long ll_r defines a long integer variable ll_r.

Ll_r = dw_1.rowcount () to get the total number of datawindow data records in the control dw_1 and put them in the variable ll_r.

8. Text, Excel, and DBASE files are imported into datawindow and data export in datawindow, text, Excel, and DBASE. Import: dw_1.importfile (type, filename, startrow, endrow, startcolumn, endcolumn, ldwstartcolumn) Where dw_1 is the datawindow Control name and type is the imported file type. Filename is the file name, startrow is the start line of the file, and endrow is the end line of the file. Startcolumn is the start column of the file, endcolumn is the end column of the file, and ldwstartcolumn is the start column of datawindow.

For example, import the columns 2nd to 3rd of the 8 rows of the cdisk test.txt file to datawindow, and import the data to the end of row 6th in datawindow.

Dw_1.importfile (Text !," C:/test.txt ", 2, 8, 3, 6, 46)

Export: dw_1.saveas (filename, saveastype, colheading) Where dw_1 is the datawindow Control name, filename is the exported file name, saveastype is the exported file type, and colheading is whether to save the title.

For example, save the data in the data window to drive D and obtain the file named CS. A title is required.

Dw_1.saveas ("D: \ cs.txt", text !, True) True indicates a title. False indicates that the title is not included.

9. Save data in the data window. Dw_1.update () Where dw_1 is the datawindow Control name

For example, you must save the modified data. Use this statement.

Dw_1.update () The statement has a return value. If 1 is returned, the update is successful, and-1 is returned, indicating an error.

10. The message box is displayed. MessageBox (title, text, icon, button, default), title is the title, text is the message content, icon is the icon, button is the display button, delfault indicates the default button.

For example, a message box is displayed, with the title "delete confirmation". The content is "are you sure you want to delete this record? the icon is" Inquiry ", and the buttons are" OK "and" cancel ". The default value is" cancel.

MessageBox ("confirm deletion", "Are you sure you want to delete this record?", question !, Okcancel !, 2)

11. Search for functions. Dw_1.find (expression, start, end), where dw_1 is the datawindow Control name, expression is the search condition expression, start is the start row, and end is the end row.

For example, you can search for records with the column name ID equal to 8 in the first 10 rows.

Dw_1.find ("ID = 8",) returns the row number.

This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/xujuntao0000/archive/2010/11/09/5997732.aspx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.