|
of_getkeyvalue
|
|
Full name
|
pfc_n_cst_string.of_getkeyvalue
|
Access
|
public
|
Extend of
|
string
|
Return value
|
string
|
Prototype
|
public function string of_getkeyvalue(string,string,string)
|
Name
|
Datatype
|
lb_done
|
boolean
|
li_equal
|
integer
|
li_keyword
|
integer
|
li_separator
|
integer
|
ls_exact
|
string
|
ls_keyvalue
|
string
|
ls_null
|
string
|
ls_source
|
string
|
public function string of_getkeyvalue (string as_source, string as_keyword, string as_separator);//////////////////////////////////////////////////////////////////////////////
//
// Function: of_GetKeyValue
//
// Access: public
//
// Arguments:
// as_source The string to be searched.
// as_keyword The keyword to be searched for.
// as_separator The separator character used in the source string.
//
// Returns: string
// The value found for the keyword.
// If no matching keyword is found, an empty string is returned.
// If any argument's value is NULL, function returns NULL.
//
// Description: Gets the value portion of a keyword=value pair from a string.
//
//////////////////////////////////////////////////////////////////////////////
//
// Revision History
//
// Version
// 5.0 Initial version
// 6.0.01 Make function find only an exact match of the keyword
//
//////////////////////////////////////////////////////////////////////////////
//
// 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.
//
//////////////////////////////////////////////////////////////////////////////
boolean lb_done=false
integer li_keyword, li_separator, li_equal
string ls_keyvalue, ls_source, ls_exact
//Check parameters
If IsNull(as_source) or IsNull(as_keyword) or IsNull(as_separator) Then
string ls_null
SetNull (ls_null)
Return ls_null
End If
//Initialize key value
ls_keyvalue = ''
do while not lb_done
li_keyword = Pos (Lower(as_source), Lower(as_keyword))
if li_keyword > 0 then
ls_source = as_source
as_source = LeftTrim(Right(as_source, Len(as_source) - (li_keyword + Len(as_keyword) - 1)))
// see if this is an exact match. Either the match will be at the start of the string or
// the match will be after a separator character. So check for both cases
li_equal = li_keyword - len(as_separator)
If li_equal > 0 Then
// not the start so see if this is a compound occurance separated by the separator string
ls_exact = mid(ls_source, li_equal, len(as_separator))
If ls_exact <> as_separator Then
// not the separator string so continue looking
Continue
End IF
End If
if Left(as_source, 1) = "=" then
li_separator = Pos (as_source, as_separator, 2)
if li_separator > 0 then
ls_keyvalue = Mid(as_source, 2, li_separator - 2)
else
ls_keyvalue = Mid(as_source, 2)
end if
ls_keyvalue = Trim(ls_keyvalue)
lb_done = true
end if
else
lb_done = true
end if
loop
return ls_keyvalue
end function
Name
|
Owner
|
systemfunctions.isnull |
systemfunctions
|
systemfunctions.left |
systemfunctions
|
systemfunctions.lefttrim |
systemfunctions
|
systemfunctions.len |
systemfunctions
|
systemfunctions.lower |
systemfunctions
|
systemfunctions.mid |
systemfunctions
|
systemfunctions.mid |
systemfunctions
|
systemfunctions.pos |
systemfunctions
|
systemfunctions.pos |
systemfunctions
|
systemfunctions.right |
systemfunctions
|
systemfunctions.setnull |
systemfunctions
|
systemfunctions.trim |
systemfunctions
|