如何对pb中的MultiLineEdit一行一行的写
1个回答
2015-02-07 · 知道合伙人数码行家
关注
展开全部
函数名称:f_get_substring
参数:string sarg
integer iwidth
integer icount
代码:/**************************************************
* 字符串自动折行 *
* 参数:字符串、每行字符数、回车数 *
* 返回:包含回车符的字符串 *
* 具备功能:,。)不在行首 *
* 数字不在中间折行 *
* 行尾的(...)自动折行 *
* 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
参数:string sarg
integer iwidth
integer icount
代码:/**************************************************
* 字符串自动折行 *
* 参数:字符串、每行字符数、回车数 *
* 返回:包含回车符的字符串 *
* 具备功能:,。)不在行首 *
* 数字不在中间折行 *
* 行尾的(...)自动折行 *
* 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
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询