// Function Name : f_parse_to_array
// Argument Name : as_source, Arg Type : String, Pass By : Value
// as_delimiter, Arg Type : String, Pass By : Value
// as_array[], Arg Type : String, Pass By : Reference
// Return Type : Long
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Description: Parse a string into array elements using a delimeter string.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
Long ll_DelLen
Long ll_Pos
Long ll_Count
Long ll_Start
Long ll_Length
String ls_holder
//Check for NULL
If IsNull(as_source) or IsNull(as_delimiter) Then
long ll_null
SetNull(ll_null)
Return ll_null
End If
//Check for at leat one entry
If Trim (as_source) = '' Then
Return 0
End If
//Get the length of the delimeter
ll_DelLen = Len(as_Delimiter)
ll_Pos = Pos(Upper(as_source), Upper(as_Delimiter))
//Only one entry was found
If ll_Pos = 0 Then
as_Array[1] = as_source
Return 1
End If
//More than one entry was found - loop to get all of them
ll_Count = 0
ll_Start = 1
Do While ll_Pos > 0
//Set current entry
ll_Length = ll_Pos - ll_Start
ls_holder = Mid (as_source, ll_start, ll_length)
// Update array and counter
ll_Count ++
as_Array[ll_Count] = ls_holder
//Set the new starting position
ll_Start = ll_Pos + ll_DelLen
ll_Pos = Pos(Upper(as_source), Upper(as_Delimiter), ll_Start)
Loop
//Set last entry
ls_holder = Mid (as_source, ll_start, Len (as_source))
// Update array and counter if necessary
If Len (ls_holder) > 0 Then
ll_count++
as_Array[ll_Count] = ls_holder
End If
//Return the number of entries found
Return ll_Count
// Argument Name : as_source, Arg Type : String, Pass By : Value
// as_delimiter, Arg Type : String, Pass By : Value
// as_array[], Arg Type : String, Pass By : Reference
// Return Type : Long
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Description: Parse a string into array elements using a delimeter string.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
Long ll_DelLen
Long ll_Pos
Long ll_Count
Long ll_Start
Long ll_Length
String ls_holder
//Check for NULL
If IsNull(as_source) or IsNull(as_delimiter) Then
long ll_null
SetNull(ll_null)
Return ll_null
End If
//Check for at leat one entry
If Trim (as_source) = '' Then
Return 0
End If
//Get the length of the delimeter
ll_DelLen = Len(as_Delimiter)
ll_Pos = Pos(Upper(as_source), Upper(as_Delimiter))
//Only one entry was found
If ll_Pos = 0 Then
as_Array[1] = as_source
Return 1
End If
//More than one entry was found - loop to get all of them
ll_Count = 0
ll_Start = 1
Do While ll_Pos > 0
//Set current entry
ll_Length = ll_Pos - ll_Start
ls_holder = Mid (as_source, ll_start, ll_length)
// Update array and counter
ll_Count ++
as_Array[ll_Count] = ls_holder
//Set the new starting position
ll_Start = ll_Pos + ll_DelLen
ll_Pos = Pos(Upper(as_source), Upper(as_Delimiter), ll_Start)
Loop
//Set last entry
ls_holder = Mid (as_source, ll_start, Len (as_source))
// Update array and counter if necessary
If Len (ls_holder) > 0 Then
ll_count++
as_Array[ll_Count] = ls_holder
End If
//Return the number of entries found
Return ll_Count
0 comments:
Post a Comment