谁是会员,能帮我在陶清网站下载一些例子给我

pingkeke 2002-08-26 01:35:09
http://www.pdriver.com/display.asp?key_id=1365
在pb中实现文本自动折行的函数(此...点数:5
我的邮箱是pingkeke@163.com
...全文
42 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
pingkeke 2002-08-26
  • 打赏
  • 举报
回复
to:zqllyh(找感觉), wk_1978()
你们提供的函数,就是把一大串字符传做一个参数进行处理,是很好的解决了汉字、字符的折行问题
但还有一个问题,
但我要控制每行之间要保持一定的空隙要怎么办呢,最好能这样
functionname(string,1,10)
中间空三行
functionname(string,10,20)
中间空上10行
functionname(string,30,20)

的效果,希望高手再帮我解决一下
wk_1978 2002-08-26
  • 打赏
  • 举报
回复
/**************************************************
* 字符串自动折行 *
* 参数:字符串、每行字符数、回车数 *
* 返回:包含回车符的字符串 *
* 具备功能:,。)不在行首 *
* 数字不在中间折行 *
* 行尾的(...)自动折行 *
* For PowerBuilder 8.0
**************************************************/
Integer li_i,li_count,li_begin,li_j,li_num,li_1,li_width
String ls_tmp,ls_1,ls_2,ls_return = ''

If IsNull(sArg) Then return ''

sarg = RightTrim(sarg)

li_width = len(sArg)

If li_width <= iwidth Then Return sArg

If IsNull(iCount) Or iCount < 1 Then iCount = 1

li_count = li_width / iwidth

If Mod(li_width,iWidth) <> 0 Then li_count ++

li_begin = 1

li_num = 0

For li_i = 1 To li_count
li_j = 0
li_width = 0
Do While li_width < iWidth
ls_tmp = Mid(sArg,li_begin + li_j)
If ls_tmp = '' Then exit

ls_1 = Left(ls_tmp,1)

If li_width > 0 And (ls_1 = '(' Or ls_1 = '(') Then
ls_2 = Right(ls_tmp,1)
If (ls_2 = ')' Or ls_2 = ')') And Len(ls_tmp) <= iWidth + 2 &
And li_width + Len(ls_tmp) > iWidth + 2 Then exit
End If

If (ls_1 >= '0' And ls_1 <= '9') Or ls_1 = '.' Then
li_num ++
Else
li_num = 0
End If
li_j ++
li_width = li_width + Len(ls_1)
Loop

//判断英文符号
ls_tmp = Mid(sArg,li_begin + li_j,1)

If ls_tmp = ',' Or ls_tmp = '.' Or ls_tmp = ')' &
Or ls_tmp = ',' Or ls_tmp = '。' Or ls_tmp = ')'Then li_j++

If li_num > 0 Then
If (ls_tmp >= '0' And ls_tmp <= '9') Or ls_tmp = '.' Then
li_j = li_j - li_num
End If
li_num = 0
End If

ls_return = ls_return + Mid(sArg,li_Begin,li_j)

If li_i <> li_count And Mid(sArg,li_Begin + li_j) <> '' Then
For li_1 = 1 To iCount
ls_return = ls_return + '~r~n'
Next
ElseIf li_width < iWidth - 2 And li_j <> 0 Then
ls_return = ls_return + Fill(' ',(iWidth - li_width) / 2)
End If

li_begin = li_Begin + li_j

Next

return ls_return
zqllyh 2002-08-26
  • 打赏
  • 举报
回复
//函数名:f_wordwrap
//参数1:as_text 要被处理的正文
//参数2:ai_charincol 一行放多少个字符(不包括回车)
//返回:as_tex 处理过的行

int i,li_len,j,k,l,li_totalrow
char lch_char,lch_next
string ls_wrappedtext,ls_next,ls_prev,ls_string

li_len = len(as_text)
j=0 //记ASCII大于127的字符个数
k=0 //记每一行的字符数
l =1 //每一行起始字符在正文中的位置
li_totalrow = 0
ls_wrappedtext = ""

for i=1 to li_len
lch_char = mid(as_text,i,1)
if asc(lch_char) > 127 then
j++
k++
else
if lch_char = '~r' then
li_totalrow++
k++
ls_wrappedtext += mid(as_text,l,k)
j = 0
l += k
k =0
elseif lch_char = '~n' then //新行
k++
ls_wrappedtext += mid(as_text,l,k)
l +=k
k --
else
k++
end if
end if

if k >= ai_charincol then//如一行已超过最大长度,则自动折行
lch_next = mid(as_text,i+1,1)
ls_next = mid(as_text,i+1,2)
ls_prev = mid(as_text,i,2)

if lch_next = '~r' or lch_next = '~n' then
continue
elseif lch_next = '.' or lch_next =',' or lch_next ='?' or lch_next ='!' &
or lch_next =')' or lch_next =']' or lch_next ='}' or lch_next =';' &
or lch_next =':' or lch_next ='~'' or lch_next ='~"' then

if i <> li_len -1 then
continue
else
exit
end if

elseif ls_prev = ',' or ls_prev ='。' or ls_prev = '?' &
or ls_prev = '!' or ls_prev = '”' or ls_prev ='’' or &
ls_prev =')' or ls_prev = ';' or ls_prev = ':' or ls_prev = '、' then

if i <> li_len -1 then
continue
else
exit
end if
elseif ls_next = ',' or ls_next ='。' or ls_next = '?' &
or ls_next = '!' or ls_next = '”' or ls_next ='’' or &
ls_next =')' or ls_next = ';' or ls_next = ':' or ls_next = '、' then

if i <> li_len -2 then
j++
i++
k++
continue
else
exit
end if
else

if mod(j,2) = 0 then
ls_wrappedtext = ls_wrappedtext + mid(as_text,l,k) + '~r~n'
else
ls_string = mid(as_text,l,k -1)
ls_wrappedtext = ls_wrappedtext + mid(as_text,l,k -1) + '~r~n'
i --
k --
end if

j = 0
l += k
k = 0
li_totalrow ++
end if
end if
next

ls_wrappedtext = ls_wrappedtext + mid(as_text,l)
as_text = ls_wrappedtext
li_totalrow ++
return ls_wrappedtext
pingkeke 2002-08-26
  • 打赏
  • 举报
回复
哎,标题写错了,只要一个例子
pingkeke 2002-08-26
  • 打赏
  • 举报
回复
提供地址给我自己下载也行(在pb中实现文片自行折行的函数)
pingkeke 2002-08-26
  • 打赏
  • 举报
回复
在线等待~~~~~~~~~~

1,108

社区成员

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

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