Home > database >  [for] PB9 parsing rarely used word problems
[for] PB9 parsing rarely used word problems

Time:09-18

I use a function analysis according to the specified separator string and returns an array of segmentation

Global type f_substr_gy from function_object
End type

Forward as
Global function integer f_substr_gy (string data_input, string data_mark, ref any ls_arr [])
End as

Global function integer f_substr_gy (string data_input, string data_mark, ref any ls_arr []);//string ls_str
//string ls_arr []
Long ll_pos, I=0, ll_start

Ll_pos=pos (data_input data_mark)
Ll_start=1

The do while ll_pos & gt; 0 and ll_pos & lt;=len (data_input)
I++
Ls_arr [I]=mid (data_input ll_start, ll_pos - ll_start)
Ll_start=ll_pos + 1
Ll_pos=pos (data_input data_mark, ll_start)
Loop

The return of I
End the function

But into the parameter such as' 1234 | abcd | abcd | ', when there is a rarely used word, will parse error, what method can solve????

CodePudding user response:

Posw can solve the problem

CodePudding user response:

The mid midw instead; Change the pos to posw can solve

CodePudding user response:

Global type f_substr_gy from function_object
End type

Forward as
Global function integer f_substr_gy (string data_input, string data_mark, ref any ls_arr [])
End as

Global function integer f_substr_gy (string data_input, string data_mark, ref any ls_arr []);//string ls_str
//string ls_arr []
Long ll_pos, I=0, ll_start

Ll_pos=posw (data_input data_mark)
Ll_start=1

The do while ll_pos & gt; 0 and ll_pos & lt;=len (data_input)
I++
Ls_arr [I]=midw (data_input ll_start, ll_pos - ll_start)
Ll_start=ll_pos + 1
Ll_pos=posw (data_input data_mark, ll_start)
Loop

The return of I
end function

CodePudding user response:

Len will also change

Global type f_substr_gy from function_object
End type

Forward as
Global function integer f_substr_gy (string data_input, string data_mark, ref any ls_arr [])
End as

Global function integer f_substr_gy (string data_input, string data_mark, ref any ls_arr []);//string ls_str
//string ls_arr []
Long ll_pos, I=0, ll_start

Ll_pos=posw (data_input data_mark)
Ll_start=1

The do while ll_pos & gt; 0 and ll_pos & lt;=lenw (data_input)
I++
Ls_arr [I]=midw (data_input ll_start, ll_pos - ll_start)
Ll_start=ll_pos + 1
Ll_pos=posw (data_input data_mark, ll_start)
Loop

The return of I
end function

CodePudding user response:

Byte length processing ~
  • Related