pb中如何实现竖排文本?

xiaoqinger 2003-11-12 09:43:14
请问在pb中如何实现输出竖排文本?
...全文
362 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
mittee 2003-11-12
  • 打赏
  • 举报
回复
//转载一个函数给你参考参考
//函数名:f_wordwrap
//参数1:as_text 要被处理的正文
// (注意as_text是定义为莚eference方式引用,会改变你程序中的值,请自行修改)
//参数2:ai_charincol 一行放多少个字符(不包括回车)
//返回:li_totalrow 总行数
//功能:实现正文的自动折行功能,且防止汉字被一切为二.

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 li_totalrow
dotnba 2003-11-12
  • 打赏
  • 举报
回复
选择带T的字体

1,072

社区成员

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

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