pb powerbuilder 把特定分割符字符串转换成字符串列表

程序开发中会需要把一些特定分割符字符串,转换乘字符串列表。比如

A|B|CD转换成

A

B

CD


1、创建函数

 2、函数主体

string  ls_list[] //接收返回的字符串列表
string  ls_temp
integer i = 1
long    ll_pos
integer li_len

li_len = len(ls_bj)    //分割符的长度
ll_pos = pos(ls_input,ls_bj)

do
    if ll_pos = 0 then 
        ls_list[i] = ls_input
    else        
        ls_list[i] = left(ls_input,ll_pos - 1)    
        i++        
       ls_input = mid(ls_input,ll_pos + li_len)
        ll_pos = pos(ls_input,ls_bj)
        if ll_pos = 0 then ls_list[i] = ls_input
    end if
loop while ll_pos <> 0

return ls_list

猜你喜欢

转载自blog.csdn.net/wosind/article/details/81169822