of_parsetoarray


pfcapsrv.pbl   >   pfc_n_cst_string   >   of_parsetoarray   

Full name pfc_n_cst_string.of_parsetoarray
Access public
Extend of long
Return value long
Prototype public function long of_parsetoarray(string,string,ref string[])

Name Datatype
No Data

Name Datatype
ll_Count long
ll_DelLen long
ll_Length long
ll_null long
ll_Pos long
ll_Start long
ls_holder string

public function long of_parsetoarray (string as_source, string as_delimiter, ref string as_array[]);//////////////////////////////////////////////////////////////////////////////
//
//	Function:  of_ParseToArray
//
//	Access:  public
//
//	Arguments:
//	as_Source   The string to parse.
//	as_Delimiter   The delimeter string.
//	as_Array[]   The array to be filled with the parsed strings, passed by reference.
//
//	Returns:  long
//	The number of elements in the array.
//	If as_Source or as_Delimeter is NULL, function returns NULL.
//
//	Description:  Parse a string into array elements using a delimeter string.
//
//////////////////////////////////////////////////////////////////////////////
//
//	Revision History
//
//	Version
//	5.0   Initial version
//	5.0.02   Fixed problem when delimiter is last character of string.

//	   Ref array and return code gave incorrect results.
//
//////////////////////////////////////////////////////////////////////////////
//
//	Copyright © 1996-1997 Sybase, Inc. and its subsidiaries.  All rights reserved.
//	Any distribution of the PowerBuilder Foundation Classes (PFC)
//	source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//
//////////////////////////////////////////////////////////////////////////////

long		ll_DelLen, ll_Pos, ll_Count, ll_Start, 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

end function

     
Name Owner
pfc_n_cst_sql.of_parse pfc_n_cst_sql
pfc_n_cst_error.of_processmessagesubstitution pfc_n_cst_error
pfc_n_cst_conversion.of_date pfc_n_cst_conversion
pfc_n_cst_conversion.of_time pfc_n_cst_conversion
pfc_n_cst_dwsrv.of_getheight pfc_n_cst_dwsrv
pfc_n_cst_dwsrv_sort.of_ParseSortAttrib pfc_n_cst_dwsrv_sort
pfc_n_cst_dssrv_report.of_gettextsizepos pfc_n_cst_dssrv_report
pfc_n_cst_dwsrv_report.of_gettextsizepos pfc_n_cst_dwsrv_report
pfc_n_cst_dssrv.of_getheight pfc_n_cst_dssrv

     
Name Owner
systemfunctions.isnull systemfunctions
systemfunctions.len systemfunctions
systemfunctions.mid systemfunctions
systemfunctions.pos systemfunctions
systemfunctions.pos systemfunctions
systemfunctions.setnull systemfunctions
systemfunctions.trim systemfunctions
systemfunctions.upper systemfunctions

     
Full name
No Data

     
Name Scope
No Data