当前位置: 代码迷 >> PB >> pb怎么分割字符串并且放入数组中
  详细解决方案

pb怎么分割字符串并且放入数组中

热度:30   发布时间:2016-04-29 06:34:17.0
pb如何分割字符串并且放入数组中
“一厂,二厂,三厂,四厂”  我要取成  一厂 二厂 三厂 四厂 并且放入数组中  高手解答高分哟
字符串截取放入数组

------解决方案--------------------
用pos函数查找“,”把各个值分配到数组中。
------解决方案--------------------
global type gf_split_parm from function_object
end type

forward prototypes
global function integer gf_split_parm (string as_parm, ref string as_data[])
end prototypes

global function integer gf_split_parm (string as_parm, ref string as_data[]);//拆分返回值
long ll_pos, ll_item

if isnull(as_parm) then
as_parm = ''
end if

if len(as_parm) <= 0 then
return 0
end if

ll_item = 0
ll_pos = pos(as_parm, ',')
do while ll_pos > 0
ll_item ++
as_data[ll_item] = left(as_parm, ll_pos - 1)
as_parm = mid(as_parm, ll_pos + 1)
ll_pos = pos(as_parm, ',')
loop
ll_item ++
as_data[ll_item] = as_parm
return ll_item
end function

------解决方案--------------------
引用:
global type gf_split_parm from function_object
end type

forward prototypes
global function integer gf_split_parm (string as_parm, ref string as_data[])
end prototypes

global function integer gf_split_parm (string as_parm, ref string as_data[]);//拆分返回值
long ll_pos, ll_item

if isnull(as_parm) then
as_parm = ''
end if

if len(as_parm) <= 0 then
return 0
end if

ll_item = 0
ll_pos = pos(as_parm, ',')
do while ll_pos > 0
ll_item ++
as_data[ll_item] = left(as_parm, ll_pos - 1)
as_parm = mid(as_parm, ll_pos + 1)
ll_pos = pos(as_parm, ',')
loop
ll_item ++
as_data[ll_item] = as_parm
return ll_item
end function


+ 1
  相关解决方案