??xml version="1.0" encoding="utf-8" standalone="yes"?>
u_sheets控g:
of_drawtabsҎ?
两处uo_paint.Drawtext(aul_hdc, istr_tabs[n].displaytext, lenA(istr_tabs[n].displaytext), istr_tabs[n].textrect, DT_END_ELLIPSIS)
修改?
uo_paint.Drawtext(aul_hdc, istr_tabs[n].displaytext, -1, istr_tabs[n].textrect, DT_END_ELLIPSIS)
of_updatepointsҎ?
lnv_win32.GetTextExtentPoint32(aul_hdc, istr_tabs[n].displaytext, LEN(istr_tabs[n].displaytext), lstr_size)
修改?
lnv_win32.GetTextExtentPoint32(aul_hdc, istr_tabs[n].displaytext, LENA(istr_tabs[n].displaytext), lstr_size)
w_tmp_resource中of_gettextwidthҎ
lnv_win32.GetTextExtentPoint32(ll_dc, as_text, LEN(as_text), lstr_size)
修改为:
lnv_win32.GetTextExtentPoint32(ll_dc, as_text, LENA(as_text), lstr_size)
轉自:http://blog.csdn.net/gogir/archive/2009/02/07/3867255.aspx
工具Qpb11.5
数据库:oracle 9
1、拷贝oracle安装目录 \jdbc\lib 下的classes12.zip到本地目录,q里有oracle的jdbc驱动
2、运行pb11Q打开tools->system
optionsQ选择java面Q在classpaths里添加刚才粘贴的classes12.zip文g的全路径以及名称Q如Qd:\mypro
\classes12.zip 。检查jvm statusQpb11默认会安装jdk1.5的?br />
3、重新启动pb10Q注意:在进行了W?步设|后必须重启pb才能使设|生效?br />
4、打开tools->database profilesQ选择JDB JDBCQ新建jdbcq接?/p>
在connection面的driver name里填写oracle.jdbc.driver.OracleDriver Q?/p>
url里填?
jdbc:oracle:thin:@127.0.0.1:1521:DB1
Q?27.0.0.1处应Z的数据库所在计机的ip地址QDB1处应Z的数据库实例名称Q?br />
5、填写login id和password后即可连接?br />
6、根据自己需要进行其他设|?/p>
下面是一个连接语?/p>
SQLCA.DBMS = "JDBC"SQLCA.LogPass = <***>SQLCA.LogId = "admin"SQLCA.AutoCommit = FalseSQLCA.DBParm = "Driver=‘oracle.jdbc.driver.oracledriver‘,URL=‘jdbc:oracle:thin:@localhost:1521:dev‘"
1、首先将DW属性中的Column Moving 和Mouse Selection 两项取消选中Q?/strong>
2、在 DW 的Clicked 事g中写代码Q?/strong>
//此处声明所用到的相兛_量;
long ll_curcol,ll_pos,ll_cols
string ls_modstring,ls_colname,ls_color_1,ls_color_2,ls_curcol
if row = 0 then return
//此处l两个颜色变量赋|
ls_color_1 = string(rgb(255,255,255))
ls_color_2 = string(15780518) //此处讄选中单元gؓSKY天蓝?/strong>
//此处获取当前列号和d敎ͼ
//ll_curcol=dw_1.getcolumn()
ls_curcol = left(dw_1.GetObjectAtPointer(),pos(dw_1.GetObjectAtPointer(),"~t") - 1)
ll_cols = long(dw_1.Object.DataWindow.Column.Count)
//此处所有列的BACKGROUND? MODE属性设Z透明Q(注:下面两句其实可以攑ֈFORM的OPEN事g或DW的CONSTRUCTOR里面执行Q可以提高效率;Q?nbsp;
dw_1.setredraw(false)
for ll_pos = 1 to ll_cols
ls_colname = dw_1.Describe("#"+string(ll_pos)+".Name")
dw_1.Modify(ls_colname+".Background.Mode='0'")
next
//此处所操作列的Background.Color属性设为带IF判断的表辑ּQ而除此之外的各列的背景表辑ּ均设为恒|
for ll_pos = 1 to ll_cols
ls_colname = dw_1.Describe("#"+string(ll_pos)+".Name")
//if ll_pos<> ll_curcol then
if ls_colname <> ls_curcol then
ls_modstring = ls_colname+".Background.Color='"+ls_color_1+"'"
else
ls_modstring = ls_colname+".Background.Color='"+ls_color_1+" ~t if (getrow()=currentrow(),"+ls_color_2+","+ls_color_1+")'"
end if
//此处执行背景颜色修改Q?/font>
dw_1.Modify(ls_modstring)
next
//h昄新的背景颜色Q?
dw_1.setredraw(true)
//inv_resize.of_Register(dw_2,inv_resize.FIXEDRIGHTbottom)
在需要用的H口中定义一个实?
n_cst_resize inv_resize;
在open事g中注册窗口上的控?
inv_resize = create nvo_resize
inv_resize.of_SetOrigSize (this.WorkSpaceWidth(),
this.WorkSpaceHeight())
inv_resize.of_Register(dw_list, 0, 0, 0, 100)
inv_resize.of_Register(st_hsplitbar, 0, 0, 0, 0)
inv_resize.of_Register(dw_main, 0, 0, 100,0)
inv_resize.of_Register(st_vsplitbar, 0, 0, 0, 0)
inv_resize.of_Register(dw_preview, 0, 0, 100, 100)
//参数:
1.控g对象
2.Ud时的X坐标位移癑ֈ?
3.Ud时的Y坐标位移癑ֈ?
4.Ud时的WIDTH坐标位移癑ֈ?
5.Ud时的HEIGHT坐标位移癑ֈ?
在resize事g中写?
inv_resize.Event wfc_Resize (sizetype, This.WorkSpaceWidth(),
This.WorkSpaceHeight())
在需要用的H口中定义一个实?
n_cst_resize inv_resize;
在open事g中注册窗口上的控?
inv_resize = create nvo_resize
inv_resize.of_SetOrigSize (this.WorkSpaceWidth(),
this.WorkSpaceHeight())
inv_resize.of_Register(dw_list, 0, 0, 0, 100)
inv_resize.of_Register(st_hsplitbar, 0, 0, 0, 0)
inv_resize.of_Register(dw_main, 0, 0, 100,0)
inv_resize.of_Register(st_vsplitbar, 0, 0, 0, 0)
inv_resize.of_Register(dw_preview, 0, 0, 100, 100)
//参数:
1.控g对象
2.Ud时的X坐标位移癑ֈ?
3.Ud时的Y坐标位移癑ֈ?
4.Ud时的WIDTH坐标位移癑ֈ?
5.Ud时的HEIGHT坐标位移癑ֈ?
在resize事g中写?
inv_resize.Event pfc_Resize (sizetype, This.WorkSpaceWidth(),
This.WorkSpaceHeight())
// Register the controls with the SplitBar
st_v1.of_Register(dw_1, st_v1.left)
st_v1.of_Register(lv_1, st_v1.right)
转自Q?a style="color: red" >http://www.pb9.com.cn/showtopic-190.html
DataWindow caching Debugging Error Application preference Most recently uesed object Security Transaction registration |
MicroHelp Help File Version Logo bitmap Copyright notice DDETimeOut property DisplayName property DWMessage Title property MicrohelpDefault property RightToLeft property ToolbarFrameTitle property ToolbarPopMenuText property ToolbarSheetTitle property ToolbarUserControl property Application preference service 同时保存如下的用户信? ToolbarText property ToolbarTips property User ID |
IF this.of_IsRegistryAvailable() THEN this.inv_apppref.of_SetAppKey(this.of_GetAppKey()) this.inv_ apppref.of_SetUserKey(this.of_GetUserKey()) ELSE this.inv_apppref.of_SetAppINIFile(this.of_GetAppINIFile()) this.inv_ap ppref.of_SetUserINIFile(this.of_GetUserINIFile()) END IF |
this.inv_apppref.of_SetRestoreApp(TRUE) this.inv_apppref.of_SetRestoreUser(TURE) |
IF this.of_IsRegistryAvailable() THEN this.inv_mru.of_SetUserKey(this.of_GetUserKey()) ELSE this.inv_mru.of_SetUserINIFile(this.of_GetUserINIFile()) END IF (3) Register IDs with the MRU service by calling the n_cst_mru of_Regis ter function. An ID is the identifier that the window will use to retr ieve information out of the MRU service. This is an example of code yo u can add to the pfc_PreOpen event of the MDI frame window: IF IsValid(gnv_app.inv_mru) THEN gnv_app.inv_mru.of_Register("myapp") END IF (4) Extend the pfc_MRUProcess event in each window that uses exclusive processing, adding code to open the sheet passing the necessary argume nts (be sure to add similar code to the frame window if you want to sp ecify exclusive items on the frame menu): Window lw_frame, lw_window n_cst_menu lnv_menu n_cst_mruattrib lnv_mru attrib // Check parameters. IF IsNull(ai_row) THEN Return -1 END IF IF NOT IsValid(gnv_app.inv_mru) THEN Return -1 END IF // Retrieve row from DataStore. gnv_app.inv_mru.of_GetItem & (ai_row, lnv_mruattri b) // Get the MDI frame, if necessary. lnv_menu.of_GetMDIFrame(this.me nuid, lw_frame) OpenSheet(lw_window, & lnv_mruattrib.is_classname, lw_frame) Return 1 Performing other actions in the pfc_MRUProcess eventTo see other types of processing you can perform in the pfc_MRUProcess event, see the co mments in the pfc_w_master pfc_MRUProcess event.5Extend the pfc_PreMRU Save event in each window that uses the MRU service. In this event, po pulate the n_cst_mruattrib object with the id, classname, key, item, a nd MicroHelp to be saved: anv_mruattrib.is_id = "myapp" anv_mruattrib.is_classname = this.ClassN ame() anv_mruattrib.is_menuitemname = this.Title anv_mruattrib.is_menu itemkey = this.ClassName() anv_mruattrib.is_menuitemmhelp = & "O pens " + this.Title Return 1 6Extend the pfc_MRURestore event in eac h window that uses the MRU service. In this event, set the ID of the i nformation you want to display on the menu: If IsValid(gnv_app.inv_mru) Then Return gnv_app.inv_mru.of_Restore ("myapp", This) End If |
PFC uses predefined messages in certain situations. If you enable the error message service and receive message display errors, make sure th e error message source has been established correctly. Additional user -defined messages must conform to the format of the messages table (al so used by the d_definedmessages DataWindow object). |
this.inv_error.of_SetNotifySeverityQ?Q? this.inv_error.of_SetLogSeverityQ?Q? |
this.inv_error.of_SetNotifyConnection(ims_mailsess) this.inv_error.of _SetNotifyWho(is_autonotify) |
IF NOT gnv_app.inv_security.of_SetSecurity(this) THEN MessageBox("Security","Unable to set security") Close(this) End if |
Datawindow service的基c?n_cst_dwsrv Dropdown search service n_cst_dwsrv_dropdownsearch Filters service n_cst_dwsrv_filter Find andreplace service n_cst_dwsrv_find Linkage service n_cst_dwsrv_linkage Multitable update service n_cst_dwsrv_multitable Print preview service n_cst_dwsrv_printpreview DataWindow property service n_cst_dwsrv_property Querymode service n_cst_dwsrv_querymode Reporting service n_cst_dwsrv_report Required column service n_cst_dwsrv_reqcolumn DataWindow resize service n_cst_dwsrv_resize Row management service n_cst_dwsrv_rowmanager Row selection service n_cst_dwsrv_rowselection Sort service n_cst_dwsrv_sort |
Integer li_return String ls_file[] li_return = inv_filesrv.of_FileRead(sle_filename.text, ls_file) CHOOSE CASE li_return CASE ? MessageBox("Error", "Error accessing file") CASE ELSE // File processing goes here END CHOOSE |
String ls_keys[] Integer li_count, li_size Li_size = inv_ini_handler.of_GetKeysQgnv_app.of_GetAppINIFileQ)Q? CustApp s_keysQ? Lb_keys.ResetQ) For li_count = 1 to li_size Lb_keys.AddItemQls_keys[li_count]Q? Next |
Long ll_base10 String ls_binary Ll_base10 = LongQsle_base10.textQ? Ls_binary = inv_numerical.of_BinaryQll_base10Q? MessageBox("Numerical", String(ll_base10) + " base 10 is equal to " + String(ll_base10) + " base 10 is equal to " + ls_binary + " in binary. ") |
Long ll_free_monery ll_free_memory = inv_platform.of_GetFreeMemoryQ) gnv_app.of_GetFrameQ). SetMicroHelpQ擣ree memoryQ?+ StringQll_ free_memoryQ) |
long ll_found
IF not(isnull(ls_keyword) or ls_keyword = '') then
IF ls_type1 = 'long' THEN
ll_found = dw_base.Find(""+sColumnName+" = "+ls_keyword+"",1,dw_base.RowCount())
ELSE
ll_found = dw_base.Find(""+sColumnName+" = '"+ls_keyword+"'",1,dw_base.RowCount())
END IF
dw_base.ScrollToRow(ll_found)
dw_base.SetRow(ll_found)
sle_1.setfocus()
PB数据H口使用SetSqlSelectQ)函数应注意的问题
Limitations to using SetSQLSelectUse SetSQLSelect only if the data source for the DataWindow object is a SQL SELECT statement without retrieval arguments and you want PowerBuilder to modify the update information for the DataWindow object:
dw_1.Modify("DataWindow.Table.Select='select...'")
Modify will not verify the SELECT statement or change the update information, making it faster but more susceptible to user error. Although you can use Modify when arguments are involved, it is not recommended because of the lack of checking.
在脚本中修改数据H口语法Ӟ如果數據H口沒有檢烦條gQ可以?font face="Times New Roman">Getsqlselectdsql语句Q修改ؓ自己需要的sql语句后可?font face="Times New Roman">Setsqlselect重新讄查询条gQ也可以?font face="Times New Roman">MODIFYQ)函数修改Q如讄不同?font face="Times New Roman">where条gQ另外设|过后要恢复原来数据H口?font face="Times New Roman">sql语句?/p>
如果有检索条件就不能?font face="Times New Roman">setsqlselectQ?/p>
只可以用dw_1.Modify("DataWindow.Table.Select='select...'")
EgQ?/p>
ls_original=dw_1.getsqlselect()
if rb_3.checked=true then //base salary
ls_newsql=ls_original +" and (staff_master.monthly_pay=0 )"
else // fixed salary
ls_newsql=ls_original +" and (staff_master.monthly_pay in ('1','2','3') )"
end if
//int i
//i=dw_1.setsqlselect(ls_newsql) //// 数据H口没有讄索参数可以用setsqlselect
string ls_tmp
//ls_tmp="DataWindow.Table.Select='"+ls_newsql+"'"http://// 加入?font face="Times New Roman">where条g中用到单引号‘’q时dw_1.Modify("DataWindow.Table.Select='select...'")中的单双引号应互?/p>
ls_tmp='DataWindow.Table.Select="'+ls_newsql+'"'
ls_tmp=dw_1.Modify(ls_tmp) ////有检索参数就只能?font face="Times New Roman">dw_1.modify()
dw_1.setsqlselect(ls_original)
PBpȝ函数 ?
日期旉函数Day()
—————————————————————————?
功能得到日期型数据中的号?1?1之间的整数??br />
语法Day ( date )
参数dateQ要得到h的日期D回?
Integer。函数执行成功时q回h(1?1之间的整数?。如果date参数的gؓNULLQ则Day()函数q回NULL?br />
—————————————————————————?#8211;
DayName()
功能得到指定日期是一周中的星期几(例如QSunday, Monday…)?br />
语法DayName ( date )
参数dateQdatecd值或变量q回值String。函数执行成功时q回指定日期的星期表C?例如QSunday,
Monday…)。如果date参数的gؓNULLQ则DayName()函数q回NULL?br />
—————————————————————————?#8211;
DayNumber()
功能得到日期型数据是一星期中的W几???之间的整数表C,星期天ؓ1Q星期一?Q?#8230;)?br />
语法DayNumber ( date )
参数dateQdatecd值或变量q回值Integer。函数执行成功时q回指定日期是一星期中的W几??~7表示Q星期天?Q星期一?
2Q?#8230;)。如果date参数的gؓNULLQ则DayNumber()函数q回NULL?br />
—————————————————————————?#8211;
DaysAfter()
功能得到两个日期间的天数?br />
语法DaysAfter ( date1, date2 )
参数date1QdatecdQ指定v始日期date2QdatecdQ指定终止日期返回值Long。函数执行成功时得到两个日期之间的天数。如?
date2的日期在date1的前面,那么DaysAfter()函数q回负倹{如果Q何参数的gؓNULLQ则DaysAfter()函数q回
NULL?br />
—————————————————————————?#8211;
Hour()
功能得到旉g的小Ӟ采用24时制?br />
语法Hour ( time )
参数timeQtimecd的D回值Integer。函数执行成功时得到time参数中的时Q?0?3之间Q。如果time参数的gؓNULLQ则
Hour()函数q回NULL?br />
—————————————————————————?#8211;
Minute()
功能得到旉g的分钟,有效值在00?9之间?br />
语法Minute ( time )
参数timeQtimecd的D回值Integer。函数执行成功时得到time参数中的分钟Q?0?9之间Q。如果time参数的gؓNULLQ则
Minute()函数q回NULL?br />
—————————————————————————?#8211;
Month()
功能得到日期g的月份,有效值在1?2之间?br />
语法Month ( date )
参数dateQdatecd的D回值Integer。函数执行成功时得到date参数中的月䆾Q??2之间Q。如果date参数的gؓNULLQ则
Month()函数q回NULL?br />
—————————————————————————?#8211;
Now()
功能得到客户机的当前pȝ旉Q返回gؓTimecd?br />
语法Now()q回值Time。该函数q回客户机的当前pȝ旉?br />
—————————————————————————?#8211;
RelativeDate()
功能得到指定日期前多天或后多少天的日期?br />
语法RelativeDate(date,n)
参数dateQDatecdQ指定基准日期nQintegercdQ指定天数返回值Date。当n的值大?时返回参数date指定日期后第n天的日期Q?
当n的值小?时返回参数date指定日期前第n天的日期。如果Q何参数的gؓNULLQ则RelativeDate()函数q回NULL?br />
—————————————————————————?#8211;
RelativeTime()
功能得到指定旉前多秒或后多少U的旉Q采?4时制?br />
语法RelativeTime ( time, n
)参数timeQtimecdQ指定基准时间nQlongcdQ指定秒数返回值Time。当n的值大?时返回参数time指定旉后第nU的旉Q当n
的值小?时返回参数time指定旉前第nU的旉。如果Q何参数的gؓNULLQ则RelativeTime()函数q回NULL?br />
—————————————————————————?#8211;
Second()
功能得到旉g的秒Q有效值在00?9之间?br />
语法Second ( time )
参数timeQtimecd的D回值Integer。函数执行成功时得到time参数中的U(00?9之间Q。如果time参数的gؓNULLQ则
Second()函数q回NULL?br />
—————————————————————————?#8211;
Today()
功能得到当前pȝ日期Q在某些情况下,同时得到当前pȝ旉?br />
语法Today()q回值Date。该函数q回当前pȝ日期。用法单独调用Today()函数Ӟ该函数Lq回当前pȝ日期Q但是,虽然Today()
函数的返回值类型ؓDateQ在该函数用做某些函数的参数、而该参数要求DateTimecd的值时QToday()函数也能够在q回当前pȝ日期的同?
q回当前pȝ旉。再如,Today()函数作ؓ数据H口控gSetItem()函数的参敎ͼ该函数参C指定的数据窗口列的数据类型ؓ
DateTimeQ那么当前系l日期和旉同时设|到数据H口指定中?br />
—————————————————————————?#8211;
Year()
功能得到日期g的年?有效取?000?000)?br />
语法Year(date)
参数dateQdatecd的D回值Integer。函数执行成功时得到date参数中的q䆾Q采用四位数字)Q发生错误时q回1900Q如果date
参数的gؓNULLQ则Year()函数q回NULL。用法当应用E序把有两位数字表示q䆾的字W串转换成日期时QPowerBuilderҎ下述规则
选择世纪Q如果年份值在00?9之间QPowerBuilder年份中的世U(前两位数字)当作20Q如果年份值在50?9?
_PowerBuilder年份中的世U(前两位数字)当作19。比如,字符?#8221;20-10-25″被PowerBuilder转换?
2020-10-25Q字W串”98-10-25″被PowerBuilder转换?998-10-25。因此,如果应用E序中需要指?950q之?
的日期,应该使用四位数字表示q䆾Q以避免引v歧义。PowerBuilder能够处理的年份从1000?000之间?/span>
函数语法Q?格式一QString ( data, { format } )
格式二:String ( Blob )
dataQ要q行cd和格式{换的数据Q可以是date、DateTime、数字类型、time? 者stringcd?
formatQ格式串Q用来指定参数data的显C格式? Ҏ参数data的数据类型的不同而不同。当参数data为StringcdӞ该参数是必需的,否则没有必要用该函数了?
q??| String。函数执行成功时q回以字W串方式表示的指定数据,如果data参数的数据类型与format参数指定的格式不匚w、format参数指定? 格式无效、或data参数不是前面提到的适宜数据cdӞString()函数q回I字W串Q?"Q?
使用说明Qformat是个用掩码表C的字符Ԍ参数data的类型不同有不同的用法:
对data参数为数值类型的情况来说Q格式ؓQ?
正数格式Q负数格式;零的昄格式Q?
I的昄格式除第一部分必须提供外,其它部分可以省略。数值型昄格式中用两个掩码字W:#?Q其中,使用#代表0"9之间的Q意数 字,0代表每个雉要显C。另外,货币W号Q?或EQ、百分号Q?Q、小数点Q?Q、逗号Q,Q等字符也可以出现在格式字符串中Q但是,除小数点Q?Q? 逗号Q,Q能够出现在格式字符#?之间外,其它字符只能攄在格式串的前面或后面Q例如,###,###$###是个错误的格式串Q? K?##,###,###是个正确的格式串。省略format参数ӞString()函数使用PowerBuilder~省格式。注意,如果昄格式? 多个部分Q各部分之间的分PQ)不能省略。其它字W也可以出现在显C格式字W串中(只能攑֜格式串的开头和末尾Q,但它们没有特D意义,pȝ只是照原? 昄。例如,用显C格式字W串“收入##”格式化数?2Ӟ昄l果?#8220;收入12”?
对data参数为字W串QStringQ类型的情况来说Qformat参数的语法格式ؓQ?
正常字符串格式;I值时格式
?#8220;正常字符串格?#8221;中,@代表字符串中的Q意字W,除此之外的Q何字W照原样昄Q例如,如果定义了下面的格式Q?
Q@@Q@@@@-@@@@
则字W串0166767593昄为:
Q?1Q?676-7593
对data参数为日期(DateQ类型的情况? _format参数的语法格式ؓQ?
正常日期格式Q日期ؓI值时的格?
日期格式中格式字W意义如下:
d -- 开头不?的日敎ͼ?Q?
dd -- 开头带0的日敎ͼ?8Q?
ddd -- 星期的英文羃写(如Mon、TueQ?
dddd -- 星期的英文全Uͼ如Monday、TuesdayQ?
m -- 开头不?的月份(?Q?
mm -- 开头带0的月份(?8Q?
mmm -- 月䆾的英文羃写(如Jan、FebQ?
mmmm -- 月䆾的英文全Uͼ如January、FebruaryQ?
yy -- 两位数字表示的年份(?7Q?
yyyy -- 四位数字表示的年份(?997Q?
另外Q还可以使用下面的关键字作ؓ日期的显C? 格式Q?
[General] Windowspȝ中定义的短日期格?
[LongDate] Windowspȝ中定义的长日期格?
[ShortDate] Windowspȝ中定义的短日期格?
对data参数为时_TimeQ类型的情况来说Q语法格式ؓQ?
正常旉格式Q时间ؓI值时的格?
旉格式中格式字W意义如下:
h -- 开头不?的小Ӟ比如6Q?
hh -- 开头带0的小Ӟ比如06Q?
m -- 开头不?的分钟(比如6Q?
mm -- 开头带0的分钟(比如06Q?
s -- 开头不?的秒Q比?Q?
ss -- 开头带0的秒Q比?6Q?
f -- 开头不?的微U,可以指定1"6个fQ每个f代表一部分微秒
AM/PM -- 用AM/PM昄上、下午时_12时?
am/pm -- 用am/pm昄上、下午时_12时?
A/P -- 用A/P昄上、下午时_12时?
a/p -- 用a/p昄上、下午时_12时?
另外Q显C格式中q可以用关键字 [Time]Q它表示按当前Windowspȝ定义的格式显C时间?nbsp;
? data参数为日期时_DateTimeQ类型的情况来说Q语法格式ؓQ?
正常 日期旉格式Q日期时间ؓI值时的格?
日期旉cd使用的掩码就是把日期掩码? 旉掩码l合h卛_?
代码实例Q?
?、下面的语句指定日期{换ؓQ?Jan 1,1998的格式:
string(1998-01-31,”mmmm dd,yyyy”)
?、下面的语句把DateTimecd的D{换ؓQJan 1,1998 6 hrs and 8 min的字W串Q?
string(DateTime(1998-01-31,06:08:00),’mmmm dd,yyyy h “hrs and” m ”min”’)
?、下面的 语句把string1讄?123Q?
integer li_num = 123
string ls_temp
ls_temp = string(li_num,”0000;(000);****;I?#8221;)
?、下面的语句把string1讄?23Q?
integer li_num = -123
string ls_temp
ls_temp = string(li_num,”000;(000);****;I?#8221;)
?、下面的语句把string1讄?***Q?
integer li_num = 0
string ls_temp
ls_temp = string(li_num,”0000;(000);****;I?#8221;)
?、下面的语句把string1讄为空Q?
integer li_num
string ls_temp
SetNull(li_num)
ls_temp = string(li_num,”0000;(000);****;I?#8221;)
׃sql server中,ntext和nvarchar字段是用unicode~码存储内容的,因此php通过mssql扩展d带ntext和nvarcharcd字段的时候会抱错?/p>
如果 title 字段cd?nvarcharQcontent 字段cd?ntext Q那么下面的sql语句会报错:
select title,content from article where 1
正确的写法是Q?/p>
select convert(varchar(255),title) as title, convert(text,content) as content from article where 1
或者不使用ntext字段
可用 DataWindow.Processing 判断
DataWindow 对象的类型,dw的类型如下:
0 (Default) Form, group, query, or tabular
1 Grid
2 Label
3 Graph
4 Crosstab
5 Composite
7 RichText
CZ一Q?br /> This.Object.Datawindow.Processing = '0'
CZ二:
String ls_processing
ls_processing = idw_requestor.Describe("datawindow.Processing")
If ls_processing = "4" Then
idw_requestor.Modify("DataWindow.Crosstab.StaticMode=Yes")
End If
作用域定义变量在什么范围内有效。PowerBuilder的变量作用域共有四种Q全局变量、实例变量、共享变量和局部变量。不同作用域的变量需要在不同 的位|说明,下面分别予以介绍。在~程H口、窗口画W、用户对象画W或菜单ȝ中,选择“Declare”菜单中的“Global Variables”?/span>“Instance Variables”?/font>“Shared Variables”可以分别声明全局、实例和׃nq三cd量?/span>
全局变量
全局变量在整个应用程序中都可讉KQ它的作用域是整个应用程? ?/span>
实例变量
实例变量与对象相兌Q只有在该对象的事g处理E序或函C才能使用对象定义的实例变量。实例变量在它所兌的对象被打开时创建,被关闭时消失?/font>
׃n变量
׃n变量是一U静态变量,q不仅意味着它所在的对象关闭后再ơ打开Ӟ׃n变量依然保持对象关闭时的|而且q意味着同一个类多个实例中的同名׃n变量? 持相同的倹{?/font>
局部变?/font>
局部变量在使用它的事g处理E序或函C说明Q其作用域仅限于说明它的E序D,在该E序D늚M地方均可讉K局部变量,但其它程序段都不能访问本E序D中 的局部变量。运行程序后Q进入某个程序段Ӟpȝ自动为局部变量分配内存,退出程序段Ӟ局部变量占用的内存被释放?/font>
在字W串当中可以包括Ҏ字符。它们的写法如下Q?/font>
新行QNEWLINEQ:~n
制表W(TABQ:~t
垂直制表QVERTICAL TABQ:~v
回RQCARRIGE RETURNQ:~r
换页QFORMFEEDQ:~f
退|BACKSPACEQ:~b
双引P~"
单引P~'
弯曲W:~~
q接数据库也是指定事务对象。PowerBuilder提供了两个函敎ͼSetTrans()和SetTransObject()?br />
语法格式Q?br />
dw_control.SetTrans(TransactionObject)
dw_control.SetTransObject(TransactionObject)
其中Qdw_control是所使用的数据窗口控ӞtransactionObject是所要指定的事务对象?br />
q两个函数有一个重要的区别是在用SetTrans()函数Ӟ用户不需做Q何数据初始化或事务对象初始化工作。用户只需要在q里填充一个事务对
象,PB׃自动完成对该事物对象的初始化以及和数据库q接的工作。而用SetTransObject()函数Ӟ用户必须首先把所用的事务对象q接?
数据库上?br />
但是Q这q不意味着SetTrans()函数比SetTransObject()函数更好Q用SetTrans()函数Ӟ每调用一ơ函数必连接一?
数据库,因ؓq个函数在每个事务处理的末端都会执行Disconnect语句。与此相反,使用SetTransObject()函数可以为数据库l持一?
开放性的q接。因此在一般情况下Qؓ了提高效率,L采用SetTransObject()函数?br />
q两个函数都是成功时q回1Q发生错误时q回-1?/p>
用于索数据的函数只有一个,是Retrieve()函数?br />
语法格式Q?br />
dw_control.Retrieve()
如果数据H口控g上的数据H口对象是有索参数的Q就要在q个函数调用时加上检索参数。而且索参数必d数据H口对象中定义顺序一致?br />
此函数返回一个长整型的数据,代表索出来的数据行数。如果发生错误,返?1?/p>
当用户对数据H口对象内的数据修改后,xq些修改反映到数据库中去Ӟ必须使用Update()函数?br />
语法格式Q?br />
dw_control.Update()
q个更新可能成功Q也可能p|。一般在q个函数被调用之后,L要做一个检查。请看下面的例子Q?br />
Int li_return
li_return = dw_1.Update()
IF li_return = 1 THEN
COMMIT USING SQLCA;
ELSE
ROLLBACK USING SQLCA;
END IF
在这D代码中Q首先对数据H口控gq行更新操作。但是更新只是把数据写入到客h的内存,q没有提交到数据库中。如果更新成功,把它提交到数据库中Q如
果更新失败,回滚到当前的事务?br />
行操?/span>
行操作的函数主要是对数据库中的数据进行插入、删除或选择操作?br />
在DataWindow中插入一行,可以使用InsertRow()函数?br />
语法格式Q?br />
dw_control.InsertRow(rownumber)
dw_control是数据窗口控件名Qrownumber是要插入行的的行受如果这个参Cؓ0Q代表在当前DataWindow的最后一行插入一I?
行?br />
InsertRow()函数q回一个长整型|以此来代表插入的行号。如果插入失败,则返?1?/p>
要删除DataWindow内的一行数据,则要使用DeleteRow()函数?br />
语法格式Q?br />
dw_control.DeleteRow(rownumber)
其中rownumber是要删除的行受如果该gؓ0Q表C删除当前行。如果删除成功,q回1Q失败则q回-1?/p>
如果要设|DataWindow中的某行为当前行Q可以用SetRow()函数?br />
语法格式Q?br />
dw_control.SetRow(rownumber)
其中rownumber是要讄为当前行的行受如果函数返?表示成功Q返?1代表p|?/p>
如果惌获取DataWindow中的某行为当前行Q可以用GetRow()函数?br />
语法格式Q?br />
dw_control.GetRow()
该函数没有参敎ͼ它返回一个长整型Q代表当前行受如果返?1代表p|。如果返?代表没有选中M行?/p>
如果惌在DataWindow中加亮显C某一行或取消加亮昄某一行,可以使用SelectRow()函数?br />
语法格式Q?br />
dw_control.SelectRow(rownumber,select)
其中Qrownumber表示要加亮或者取消加q显C的行号Q?表示所有行。select是一个布类型的|TRUE表示加亮QFALSE表示取消加亮
昄。该函数q回1时表C成功,q回-1时表C失败?br />
如果惌直接讄某一行ؓ加亮Q需要首先取消其它行的加亮显C状态,采用如下的两行代码:
dw_1.SelectRow(0,FALSE)
dw_1.SelectRow(rownumber,TRUE)
如果惌获取当前DataWindow中加亮显C的行,可以使用GetSelectRow()函数?br />
语法格式Q?br />
dw_control.GetSelectRow(rownumber)
其中Qrownumber为开始查扄行的行号Q?表示从头开始查找。该函数q回一个长整数Q表CZrownumber开始查扄一个加亮显C的行的?
受如果失败返??/p>
如果在DataWindow的末插入一行数据,而当前行是在DataWindow的中央,那么q种插入可能不会被用戯察。ؓ了改变这U情况,可以滚动
行到DataWindow的末,q样用户p发现新的改变。要滚动行,可以使用ScrollToRow()函数?br />
语法格式Q?br />
dw_control.ScrollToRow(rownumber)
该函数返?时表C成功,q回-1时表C失败?br />
与ScrollToRow()函数据功能相关的q有如下几个函数Q?br />
ScrollPriorRow()Q向上滚动一?br />
ScrollNextRow()Q向下滚动一?br />
列操?/span>
列操作类的函C要是选择指定的列和获取列的信息?br />
如果要获取当前的列号Q可以用GetColumn()函数Q如果要获取当前的列名,可以使用GetColumnName()函数?br />
语法格式Q?br />
dw_control.GetColumn()
dw_control.GetColumnName()
q两个函数都没有参数QGetColumn()函数q回一个长整型|代表当前的列PGetColumnName()函数q回当前列的列名。如果返?
0Q表C当前没有Q何列被选择q回-1表示p|?/p>
要设|某一列ؓDataWindow中的当前列,可以使用SetColumn()函数?br />
语法格式Q?br />
dw_control.SetColumn(column)
其中column既可以是列号Q也可以是列名。当该函数返?时表C成功,q回-1时表C失败?br />
数据操作
数据操作cȝ函数主要是对DataWindow中的数据q行获取、设|?br />
如果要从DataWindow的指定行和列中获取数据,p使用GetItempd的函数。这个系列的函数共有五个Q分别是对字W串、数字、日期、日期时
间和数?br />
语法格式Q?br />
dw_control.GetItemString(rownumber,column)
dw_control.GetItemNumber(rownumber,column)
dw_control.GetItemDate(rownumber,column)
dw_control.GetItemDateTime(rownumber,column)
dw_control.GetItemDecimal(rownumber,column)
其中Qrownumber参数表示行号Qcolumn可以是列h列名?/p>
与获取数据所用的函数不同Q设|DataWindow内指定行列处的数据只要用一个SetItem()函数可以了?br />
语法格式Q?br />
dw_control.SetItem(rownumber, column, value)
其中rownumber表示行号Qcolumn可以是列P也可以是列名Qvalue表示要设|的倹{但是该必须与DataWindow中指定的行列处的
数据cd一_不然PowerBuilder会报错?br />
SetItem()函数q回1时表C成功,q回-1时表C失败?/p>
如果希望对DataWindow内的数据q行重新排序Q而又不想重新从数据库中检索数据,可以使用SetSort()和Sort()函数。这两个函数一?
完成对DataWindowq行排序的功能。其中SetSort()函数用于讄如何排序QSort()函数用于对DataWindow实际q行排序?br />
语法格式Q?br />
dw_control.SetSort(expression)
dw_control.Sort()
其中expression是一个字W串Q表C排序的表达式,它的具体值是一个列名后面加一个空|然后?A"Q表C升序,?D"Q表C降序。如果有?
个列要同时进行排序,它们之间用逗号隔开?br />
例:dw_1.SetSort("name A,xh D")
q两个函数都是返?表示成功Q返?1表示p|?/p>
如果希望对DataWindow内的数据q行qo而不重新从数据库中检索数据,可以使用SetFilter()和Filter()函数。它们一起完成对?
据的qo功能。其中SetFilter()函数用来讄qo条gQFilter()函数用于对DataWindowq行qo?br />
语法格式Q?br />
dw_control.SetFiter(expression)
dw_control.Fiter()
其中expression是一个字W串Q表C滤的条gQ它实际是一个逻辑表达式?br />
例:
dw_1.SetFilter("id>\'003\' AND name like\'?\'")
dw_1.Filter()
q两个函数都是返?表示成功Q返?1表示p|?/p>
PowerBuilder提供了两个函数用于数据的查,它们是DeleteCount()和ModifiedCount()Q其作用分别是检?
DataWindow中的数据自上一ơ更新到现在Q被删除的行数和被修改的行数。它们一般在H口的CloseQuery事g中用,用来查该H口?
DataWindow中的数据是否有尚未保存的修改?br />
语法格式Q?br />
dw_control.DeleteCount()
dw.control.ModifiedCount()
它们分别q回从上一ơ更新到现在QDataWindow中被删除和被修改的行数。如果没有行被删除或被修改,那么它们q回0。如果出现错误则q回-1?br />
一般情况下Q如果窗口中含有可供修改的数据窗口对象,那么在窗口的CloseQuery事g中通常使用如下代码查数据窗口对象中是否有尚未保存的数据Q?br />
Int li_return
IF dw_1.ModifiedCount() > 0 OR dw_1.DeletedCount() >0 THEN
li_return =
MessageBox("提示","数据未保存Q是否保存?",Question!,YesNoCancel!,3)
CHOOSE CASE li_return
CASE 1
TriggerEvent(\'ue_save\')
RETURN 0
CASE 2
RETURN 0
CASE 3
RETURN 1
END CHOOSE
END IF
转自:http://hi.baidu.com/sundl2268/blog/item /ecd8c513085daa0b5baf532d%2Ehtml