|
of_globalreplace
|
|
Full name
|
pfc_n_cst_string.of_globalreplace
|
Access
|
public
|
Extend of
|
string
|
Return value
|
string
|
Prototype
|
public function string of_globalreplace(string,string,string,boolean)
|
Name
|
Datatype
|
ll_NewLen
|
Long
|
ll_OldLen
|
Long
|
ll_Start
|
Long
|
ls_null
|
string
|
ls_Source
|
String
|
public function string of_globalreplace (string as_source, string as_old, string as_new, boolean ab_ignorecase);//////////////////////////////////////////////////////////////////////////////
//
// Function: of_GlobalReplace
//
// Access: public
//
// Arguments:
// as_Source The string being searched.
// as_Old The old string being replaced.
// as_New The new string.
// ab_IgnoreCase A boolean stating to ignore case sensitivity.
//
// Returns: string
// as_Source with all occurrences of as_Old replaced with as_New.
// If any argument's value is NULL, function returns NULL.
//
// Description: Replace all occurrences of one string inside another with
// a new string.
//
//////////////////////////////////////////////////////////////////////////////
//
// Revision History
//
// Version
// 5.0 Initial version
//
//////////////////////////////////////////////////////////////////////////////
//
// 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_Start
Long ll_OldLen
Long ll_NewLen
String ls_Source
//Check parameters
If IsNull(as_source) or IsNull(as_old) or IsNull(as_new) or IsNull(ab_ignorecase) Then
string ls_null
SetNull(ls_null)
Return ls_null
End If
//Get the string lenghts
ll_OldLen = Len(as_Old)
ll_NewLen = Len(as_New)
//Should function respect case.
If ab_ignorecase Then
as_old = Lower(as_old)
ls_source = Lower(as_source)
Else
ls_source = as_source
End If
//Search for the first occurrence of as_Old
ll_Start = Pos(ls_Source, as_Old)
Do While ll_Start > 0
// replace as_Old with as_New
as_Source = Replace(as_Source, ll_Start, ll_OldLen, as_New)
//Should function respect case.
If ab_ignorecase Then
ls_source = Lower(as_source)
Else
ls_source = as_source
End If
// find the next occurrence of as_Old
ll_Start = Pos(ls_Source, as_Old, (ll_Start + ll_NewLen))
Loop
Return as_Source
end function
Name
|
Owner
|
systemfunctions.isnull |
systemfunctions
|
systemfunctions.len |
systemfunctions
|
systemfunctions.lower |
systemfunctions
|
systemfunctions.pos |
systemfunctions
|
systemfunctions.pos |
systemfunctions
|
systemfunctions.replace |
systemfunctions
|
systemfunctions.setnull |
systemfunctions
|