Len()和LenW()的问题----pb8

microsealkey 2002-08-22 02:54:52
在pb8中,len和以前版本一样,都是按内存中的字节数计数的,这样一个汉字的Len()是2。而LenW()却是按所谓的字数计数的,一个汉字的LenW()就是1。这可以看作是PB的功能增强了。
但是,其他有关的字符串函数,如left,Pos,mid等,却和以前版本完全不一样,他通过LenW()而不是Len()的方式来实现,所以left(str,len("产品1") -1)的结果仍旧是"产品1",而不会得到想要的"产品"。Sybase的初衷也许是不错的,mid()确实不改取出半个汉字来。

然而,我以前的程序是在pb6下写的。现在改成pb8后,程序无法正常运行了,只因为我的Left,Pos,Mid是希望和以前版本一致:按Len()的方式来实现。但他却按LenW()来实现。。。

现在的我,只能把程序中所有的Len()改成LenW(),但这样的改动却无疑和以前的程序是不一样的,改动了那么多,我心里非常得不踏实。

我疑惑的是:既然有了LenW(),Sybase为什么不提供LeftW(),PosW(),MidW(),而让left(),Pos(),Mid()和以前的一样呢。

不知各位大虾有没有更好的改动办法?
...全文
1192 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
sthcj 2002-08-22
  • 打赏
  • 举报
回复
在www.sybase.com.cn
microsealkey 2002-08-22
  • 打赏
  • 举报
回复
to jimly:
你是说pb8.02的left,pos,mid是和Len(),而不是LenW()一样的计数方式吗?
能告诉我补丁哪儿下吗?
jimly 2002-08-22
  • 打赏
  • 举报
回复
PB8.02改回到pb7的规则了,打补丁吧
microsealkey 2002-08-22
  • 打赏
  • 举报
回复
你们。。。说的是什么呀?!并不是我写不出,而是。。

我以前pb6.5下那个系统现在要升级到pb8,我想找个放心的办法:关于Len()的问题。
qqqdong 2002-08-22
  • 打赏
  • 举报
回复
同意up
xingxing 2002-08-22
  • 打赏
  • 举报
回复
自己写吧!!!不要全部指望别人!
pb动态创建树和菜单 forward global type w_tv from window end type type cb_2 from commandbutton within w_tv end type type cb_1 from commandbutton within w_tv end type type sle_1 from singlelineedit within w_tv end type type st_1 from statictext within w_tv end type end forward global type w_tv from window integer width = 1381 integer height = 620 boolean titlebar = true string title = "Untitled" boolean controlmenu = true windowtype windowtype = response! long backcolor = 67108864 string icon = "AppIcon!" boolean center = true cb_2 cb_2 cb_1 cb_1 sle_1 sle_1 st_1 st_1 end type global w_tv w_tv on w_tv.create this.cb_2=create cb_2 this.cb_1=create cb_1 this.sle_1=create sle_1 this.st_1=create st_1 this.Control[]={this.cb_2,& this.cb_1,& this.sle_1,& this.st_1} end on on w_tv.destroy destroy(this.cb_2) destroy(this.cb_1) destroy(this.sle_1) destroy(this.st_1) end on event open;String ls_Parm, ls_temp, ls_Name, ls_title ls_Parm = Trim( Message.StringParm ) ls_temp = Right( ls_Parm, 1 ) ls_Name = Left( ls_Parm, Lenw( ls_Parm ) - 2 ) IF ls_temp = 'T' THEN ls_title = '添加 ' + ls_Name + ' 的同类' END IF IF ls_temp = 'Z' THEN ls_title = '添加 ' + ls_Name + ' 的子类' END IF IF ls_temp = 'M' THEN ls_title = '修改 ' Sle_1.text = ls_Name Sle_1.SelectText( 1, Len( ls_Name ) ) END IF title = ls_title end event type cb_2 from commandbutton within w_tv integer x = 727 integer y = 360 integer width = 457 integer height = 128 integer taborder = 20 integer textsize = -12 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Arial" string text = "退出(&E)" boolean cancel = true end type event clicked;CloseWithReturn( Parent, '' ) end event type cb_1 from commandbutton within w_tv integer x = 165 integer y = 360 integer width = 457 integer height = 128 integer taborder = 30 integer textsize = -12 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Arial" string text = "确定(&O)" boolean default = true end type event clicked;String ls_Name ls_Name = Trim( sle_1.text ) CloseWithReturn( Parent, ls_Name ) end event type sle_1 from singlelineedit within w_tv integer x = 64 integer y = 156 integer width = 1234 integer height = 128 integer taborder = 10 integer textsize = -12 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Arial" long textcolor = 33554432 borderstyle borderstyle = stylelowered! end type type st_1 from statictext within w_tv integer x = 64 integer y = 40 integer width = 457 integer height = 72 integer textsize = -12 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Arial" long textcolor = 33554432 long backcolor = 67108864 string text = "类别名称" boolean focusrectangle = false end type

1,108

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧