|
您的位置:学院
>> 编程开发 >>
PowerBuilder >> PB问答(-)
|
PB问答(-)
|
问:我们公司想把所有的产品都标上条形码,不知如何编码,很多商场都有条码输入设备,是不是所有厂家的条码编码都是一样的?
答:如果不是特殊情况,一般用3-9码(还有许多编码规则,包括二维条码),它的编码规则是:共48个字符,每个字符由5根黑线和他们中间的4个白空组成的9个二进制数表示,且9个二进制数中必须有3个为1,因此称为3-9码。并且一个字符串还有一个起始*和一个结束*号。有关各字符的编码规则可以从书上找到。
问:如何窗口中的命令按钮响应回车?
答:定义一个按钮的用户事件ue_keydwn ,ID为pbm_keydown。
加入脚本:if key=KeyEnter! then this.triggerevent(clicked!)
问:一个external数据源的数据窗口,有没有办法使用dwcontrol.modify( "create column(...)" )在运行的时候增加列?语法应该是如何写?
答:用dwcontrol.modify(create column(...))是不可以增加在定义时没有的列的。
因为syntax中不存在该列,所以要在syntax中加入;
也就是说,现将dw的syntax用dwcontrol.Object.Datawindow.Syntax取得dw的syntax
然后增加你要加入的column的syntax。
以Gird格式为例,需要加入的内容有:
原内容:
table(column=(type=char(10) updatewhereclause=no name=a dbname="a" )
column=(type=char(10) updatewhereclause=no name=b dbname="b" )
column=(type=char(10) updatewhereclause=no name=c dbname="c" )
)
加入后内容:
table(column=(type=char(10) updatewhereclause=no name=a dbname="a" )
column=(type=char(10) updatewhereclause=no name=b dbname="b" )
column=(type=char(10) updatewhereclause=no name=c dbname="c" )
****加入内容*****
column=(type=char(10) updatewhereclause=no name=c dbname="d" )
)
同上,以下原内容:
text(name=a_t band=header font.charset="0" font.face="Arial" font.family="2" font.height="-12" font.pitch="2" font.weight="400" background.mode="1" background.color="536870912" color="0" alignment="2" border="0" x="9" y="8" height="76" width="320" text="A" )
text(band=header font.charset="0" font.face="Arial" font.family="2" font.height="-12" font.pitch="2" font.weight="400" background.mode="2" background.color="16777215" color="0" alignment="0" border="0" x="338" y="4" height="76" width="311" text="B" )
text(band=header font.charset="0" font.face="Arial" font.family="2" font.height="-12" font.pitch="2" font.weight="400" background.mode="2" background.color="16777215" color="0" alignment="0" border="0" x="658" y="4" height="76" width="311" text="C" )
column(name=a band=detail id=1 x="9" y="8" height="88" width="320" color="0" border="0" alignment="0" format="[general]" edit.focusrectangle=no edit.autohscroll=yes edit.autoselect=yes edit.autovscroll=no edit.case=any edit.codetable=no edit.displayonly=no edit.hscrollbar=no edit.imemode=0 edit.limit=0 edit.password=no edit.vscrollbar=no edit.validatecode=no edit.nilisnull=no edit.required=no criteria.required=no criteria.override_edit=no crosstab.repeat=no background.mode="1" background.color="536870912" font.charset="0" font.face="Arial" font.family="2" font.height="-12" font.pitch="2" font.weight="400" tabsequence=10 )
column(name=b band=detail id=2 x="338" y="0" height="76" width="311" color="0" border="0" alignment="0" format="[general]" edit.autohscroll=no edit.autoselect=yes edit.autovscroll=no edit.case=any edit.codetable=no edit.displayonly=no edit.hscrollbar=no edit.imemode=0 edit.limit=0 edit.password=no edit.vscrollbar=no edit.validatecode=no edit.nilisnull=no edit.required=no criteria.required=no criteria.override_edit=no crosstab.repeat=no background.mode="2" background.color="16777215" font.charset="0" font.face="Arial" font.family="2" font.height="-12" font.pitch="2" font.weight="400" tabsequence=0 )
column(name=c band=detail id=3 x="658" y="0" height="76" width="311" color="0" border="0" alignment="0" format="[general]" edit.autohscroll=no edit.autoselect=yes edit.autovscroll=no edit.case=any edit.codetable=no edit.displayonly=no edit.hscrollbar=no edit.imemode=0 edit.limit=0 edit.password=no edit.vscrollbar=no edit.validatecode=no edit.nilisnull=no edit.required=no criteria.required=no criteria.override_edit=no crosstab.repeat=no background.mode="2" background.color="16777215" font.charset="0" font.face="Arial" font.family="2" font.height="-12" font.pitch="2" font.weight="400" tabsequence=0 )
改为:
text(name=a_t band=header font.charset="0" font.face="Arial" font.family="2" font.height="-12" font.pitch="2" font.weight="400" background.mode="1" background.color="536870912" color="0" alignment="2" border="0" x="9" y="8" height="76" width="320" text="A" )
text(band=header font.charset="0" font.face="Arial" font.family="2" font.height="-12" font.pitch="2" font.weight="400" background.mode="2" background.color="16777215" color="0" alignment="0" border="0" x="338" y="4" height="76" width="311" text="B" )
text(band=header font.charset="0" font.face="Arial" font.family="2" font.height="-12" font.pitch="2" font.weight="400" background.mode="2" background.color="16777215" color="0" alignment="0" border="0" x="658" y="4" height="76" width="311" text="C" )
****加入内容*****
text(band=header font.charset="0" font.face="Arial" font.family="2" font.height="-12" font.pitch="2" font.weight="400" background.mode="2" background.color="16777215" color="0" alignment="0" border="0" x="978" y="4" height="76" width="311" text="D" )
column(name=a band=detail id=1 x="9" y="8" height="88" width="320" color="0" border="0" alignment="0" format="[general]" edit.focusrectangle=no edit.autohscroll=yes edit.autoselect=yes edit.autovscroll=no edit.case=any edit.codetable=no edit.displayonly=no edit.hscrollbar=no edit.imemode=0 edit.limit=0 edit.password=no edit.vscrollbar=no edit.validatecode=no edit.nilisnull=no edit.required=no criteria.required=no criteria.override_edit=no crosstab.repeat=no background.mode="1" background.color="536870912" font.charset="0" font.face="Arial" font.family="2" font.height="-12" font.pitch="2" font.weight="400" tabsequence=10 )
column(name=b band=detail id=2 x="338" y="0" height="76" width="311" color="0" border="0" alignment="0" format="[general]" edit.autohscroll=no edit.autoselect=yes edit.autovscroll=no edit.case=any edit.codetable=no edit.displayonly=no edit.hscrollbar=no edit.imemode=0 edit.limit=0 edit.password=no edit.vscrollbar=no edit.validatecode=no edit.nilisnull=no edit.required=no criteria.required=no criteria.override_edit=no crosstab.repeat=no background.mode="2" background.color="16777215" font.charset="0" font.face="Arial" font.family="2" font.height="-12" font.pitch="2" font.weight="400" tabsequence=0 )
column(name=c band=detail id=3 x="658" y="0" height="76" width="311" color="0" border="0" alignment="0" format="[general]" edit.autohscroll=no edit.autoselect=yes edit.autovscroll=no edit.case=any edit.codetable=no edit.displayonly=no edit.hscrollbar=no edit.imemode=0 edit.limit=0 edit.password=no edit.vscrollbar=no edit.validatecode=no edit.nilisnull=no edit.required=no criteria.required=no criteria.override_edit=no crosstab.repeat=no background.mode="2" background.color="16777215" font.charset="0" font.face="Arial" font.family="2" font.height="-12" font.pitch="2" font.weight="400" tabsequence=0 )
****加入内容*****
column(name=d band=detail id=4 x="978" y="0" height="76" width="311" color="0" border="0" alignment="0" format="[general]" edit.autohscroll=no edit.autoselect=yes edit.autovscroll=no edit.case=any edit.codetable=no edit.displayonly=no edit.hscrollbar=no edit.imemode=0 edit.limit=0 edit.password=no edit.vscrollbar=no edit.validatecode=no edit.nilisnull=no edit.required=no criteria.required=no criteria.override_edit=no crosstab.repeat=no background.mode="2" background.color="16777215" font.charset="0" font.face="Arial" font.family="2" font.height="-12" font.pitch="2" font.weight="400" tabsequence=0 )
修改后,用dwcontrol.create(syntax,errostring)
然后用dwcontrol.retrieve()更新
问:我用PB6.5编了一个小程序, 编译后运行正常, 但当我拿到另一台机上时一运行即报如下错误:
DBMS ODBC is not suproted in your current installation.
我在此机上装上PB6.5, 并COPY所有SHARE目录下的文件至当前目录等操作后仍不行, 然而如果直接在PB6.5的环境中RUN确又正常, 不知什么原因?
答:出现这个错误的原因不是 SQL ANYWHERE 的问题,是 SQLCA 的 DBMS 属性没有设置正确。大多数人在使用 PB 开发程序时关于 SQLCA 的属性设置往往爱用 ProfileString 函数,其中的文件名参数往往又不带路径,或者又使用了绝对路径。不管是那种情况,都可能出现 ProfileString 找不到文件的情况。这样 SQLCA 的 DBMS 属性就没有被赋值。所以才会出现 "DBMS NOT Support ..."字样的信息。
当然如果是相对路径的话,只会在 PB 开发环境中出现,这时只要用 PB 的文本编辑器打开 INI 文件一次,这样 PB 的当前目录又回到了 INI 文件所在目录
还有许多的初学者,采用的 INI 文件还是 PB.INI ,即:Sqlca.dbms = ProfileString ( "pb.ini", "database", "dbms", "") ,PB 每次连接一个不同的数据库都会更改 PB.iNI 。所以经常出现这种情况。而且这种程序放到另外一台机上不能运行,除非将 PB.INI 也 Copy 了。
问: 为何我在UPDATE()时,总是出现‘datawindow does not have UPDATE capability',重新生成一datawindow后还一样。当换另一个数据表的datawindow后,又能正常更新。与数据表有关吗?
答: 看看update属性,有没有选中
问:如何打印这样的结果:无论纸张如何,多行记录,都打固定行数,每页一张纸?
答:自己加空行凑足整页,再加一个用来控制的“计算列”,把想打印在不同页上的记录的“计算列”值设成不同,再按“计算列”分组分页。
问:我ODBC数据源的profiles里设了commit on disconnect项,在脚本里执行disconnect using sqlca;,sqlcacode返回0,但实际上好象并没断.sqlanywhere还在windows的任务栏里.这到底是怎么回事?
答:是因为ODBC Configuration / Options / Autostop Database选项未选。
问:数据窗口已经把文字设置到顶行,为何打印时前面却空出几行?
答:加入下面一行,保证贴着纸边打。
dw_1.Object.DataWindow.Print.Margin.Top=0
问:PB5中如何设计实现Sql Any Where数据库的备份?
答:直接copy文件就可以。另外可以执行execute immediate "dbtool ..."命令,dbtool语法你自己查一下help。
问:一个datawindow分组后,在trail group中放一compute field计算某一列的和,如何得到这些列的和?
答:给它们起个名字,用getitem可以获得,不过在分组情况下,先要用scrollttorow滚卷到该组的任何一行上(第i行),再用getitemstring(i,...)取得计算列的值。
问:如何动态的设置打印机的纸张大小
答:两个方法:
1、用printsetup()调出windows打印设置窗口进行设置。不过你的datawindow的打印属性设为默认才有效。
2、用Modify()全局性修改datawindow 的打印属性,有关打印属性具体内容,请查阅PB帮助的Print properties部分。例:dw_1.Modify("DataWindow.Print.Paper.Size = 3")
|
|
|
产品库推荐 |
|