使用Powerbuilder中数据窗口表达式访问数据

1、从数组到数据窗口到数组

This example resets the emp_name value in rows 11 through 20 to an empty string. Rows 12 to 20 are set to a default value, which may be an empty string:

string ls_empty[]

ls_empty[1] = ""

dw_1.Object.emp_name[11,20] = &

        {"","","","","","","","","",""}

This statement gets the original emp_name values in rows 11 to 20 and assigns them to elements 1 to 10 in an array of strings:

string ls_namearray[]

ls_namearray = dw_1.Object.emp_name.Original[11,20]

2、从数据窗口将数据拷贝到另一数据窗口
This example replaces all the data in the nested report in row 2 with data from dw_2. The columns in the DataWindow object in dw_2 must match the columns in the DataWindow object for the nested report:

dw_1.Object.NestRep[2].Object.Data = &

        dw_2.Object.Data

3、将删除缓冲区中的数据放到到文件中

This example gets employee IDs and last names for all the rows in the delete buffer. The IDs and names are the first two columns. It saves the information in a structure, called str_namelist, of two elements: an integer called id and a string called lastname. The structure was defined previously in the Structure painter. The list of IDs and names is then saved in the file DELETED.TXT:

integer li_fileNum

long ll_deletedrows

str_namelist lstr_namelist[]

ll_deletedrows = dw_1.DeletedCount()

lstr_namelist = &

        dw_1.Object.Data.Delete[1,1, ll_deletedrows,2]

li_fileNum = FileOpen("C:/HR/DELETED.TXT", &

        LineMode!, Write!)

FOR ll_count = 1 to UpperBound(lstr_namelist)

        FileWrite(li_fileNum, &

            String(lstr_namelist.id) + &

            " " + &

            lstr_namelist.lastname + &

            "~r~n")

NEXT

FileClose(li_fileNum)

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
数据窗口源码介绍 (举例见d_dbit_example.srd,测试数据库为PB自带的EAS Demo DB V120) 1.第一行:release 12; 数据窗口所属PB的版本号,如果想把高版本的datawindow导入低版本的PB要修改此数字; 2.datawindow()行 通常用修改processing属性,可以把你的数据窗口由grid变成freeform或其它类型 例:freeform:0 grid:1 3.header()行 可以整行复制粘贴,并命名为header[1],header[2],这样可以让数据窗口有多个header 4.table()行 这里全是定义的数据属性,是setitem,update,object.data等方法访问的根源 如果存在table()里的column,数据窗口里可以不存在任何对象,仍然可以访问数据窗口数据 如果想创建一个空的数据窗口,可以只定义: release 12; table() 5.table(column行) 是第几个column,它的ID就是多少,其也定义了是否可以update时和更新到数据的字段名 6.table(retrieve行) 检索数据使用的SQL语句,可以通过setsqlselect或modify("table.sqlselect")方法去动态修改 修改后要重新定义数据窗口的更新属性 7.column()行 id即是对应table(column行)里的行次,名称(name)可以随便命名,也可以没有,则默认为table(column行)里的name 8.compute()行 计算列,可以通过达式计算显示特定值(具体函数可以见共享里的画笔函数). 9.text()行 有时可以代替计算列; 通过定义text的达式,可以实现一列显示两个字段值,注意结果必须要转换成string类型(而column和compute则不行); 10.htmltable()行 按照格式导出(saveas)html文件,为了保证格式的完整,数据窗口的单位最好设置成pixels GenerateCSS='1' //保持格式及颜色 Border='0' //不要table边框 CellSpacing='0' //单元格无间距(此项在界面上经常设置不上) 注: (1)Grid生成<Table>标签,Freeform生成<DIV> + <SPAN>标签; (2)生成htmltable时,不知为何会在CSS的开始自动加一个分号";",导致excel等浏览器打开不能正常显示格式; (3)band为foreground或background的对象导不出来,可以动态修改后再导出. 11.export.xml()行 定义导出xml文件的格式,并为模板保存名称 使用时一定要设置usetemplate值 12.import.xml()行 定义导入xml文件的格式,并为模板保存名称 使用时一定要设置usetemplate值 13.达式介绍 略 14.其它也略

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值