diff options
author | Oliver Bolte <obo@openoffice.org> | 2008-05-28 07:25:41 +0000 |
---|---|---|
committer | Oliver Bolte <obo@openoffice.org> | 2008-05-28 07:25:41 +0000 |
commit | bbe05eff3cc128d887afe715ac50484108d523c9 (patch) | |
tree | 802a62c16fabcd9a0b30e4e2e9dc384b24a50b9c /wizards/source/tools | |
parent | a0feab74b55dfbe6f0400e97fa840b027185a5a0 (diff) |
INTEGRATION: CWS extrasso9 (1.27.508); FILE MERGED
2008/05/05 12:52:40 va 1.27.508.1: #i78503# ReplaceString and ArrayOutOfString Functions in Tools/String module refinement.
Issue number:
Submitted by:
Reviewed by:
Diffstat (limited to 'wizards/source/tools')
-rw-r--r-- | wizards/source/tools/Strings.xba | 67 |
1 files changed, 16 insertions, 51 deletions
diff --git a/wizards/source/tools/Strings.xba b/wizards/source/tools/Strings.xba index 6dce4d6695f5..e6cf77b37074 100644 --- a/wizards/source/tools/Strings.xba +++ b/wizards/source/tools/Strings.xba @@ -108,41 +108,19 @@ End Function ' Retrieves an Array out of a String. ' The fields of the Array are separated by the parameter 'Separator', that is contained ' in the Array -' The Array MaxLocindex delivers the highest Index of this Array -Function ArrayOutOfString(BigString, Separator as String, Optional MaxIndex as integer) -Dim i%, OldPos%, Pos%, SepLen%, BigLen% -Dim CurUbound as Integer -Dim StartUbound as Integer - StartUbound = 50 - Dim LocList(StartUbound) as String - CurUbound = StartUbound - OldPos = 1 - i = -1 - SepLen = Len(Separator) - BigLen = Len(BigString) - Do - Pos = Instr(OldPos,BigString, Separator) - i = i + 1 - If Pos = 0 Then - LocList(i) = Mid(BigString, OldPos, BigLen - OldPos + 1 ) - Else - LocList(i) = Mid(BigString, OldPos, Pos-OldPos ) - OldPos = Pos + SepLen - End If - If i = CurUbound Then - CurUbound = CurUbound + StartUbound - ReDim Preserve LocList(CurUbound) as String - End If - Loop until Pos = 0 - If Not IsMissing(Maxindex) Then - MaxIndex = i - End If - If i <> -1 Then - ReDim Preserve LocList(i) as String - Else - ReDim LocList() as String - End If - ArrayOutofString = LocList() +' The Array MaxIndex delivers the highest Index of this Array +Function ArrayOutOfString(BigString, Separator as String, Optional MaxIndex as Integer) +Dim LocList() as String + LocList=Split(BigString,Separator) +' The following line has no effect because it seems that Optional variables are +' always passed as ByValue variables. But MaxIndex must remain in the function for +' compatibility reasons +' The user of the function can always use ubund on the return value to get the +' highest index of the array. + +' If not isMissing(MaxIndex) then maxIndex=ubound(LocList()) + + ArrayOutOfString=LocList End Function @@ -294,21 +272,7 @@ End Function ' Replaces the string "OldReplace" through the String "NewReplace" in the String ' 'BigString' Function ReplaceString(ByVal Bigstring, NewReplace, OldReplace as String) as String -Dim i%, OldReplLen%, BigLen% - - If NewReplace <> OldReplace Then - OldReplLen = Len(OldReplace) - i = 1 - Do - Biglen = Len(BigString) - i = Instr(i,BigString,OldReplace) - If i <> 0 then - BigString = Mid(BigString,1,i-1) & NewReplace & Mid(BigString,i + OldReplLen,BigLen - i + 1 - OldReplLen - i = i + Len(NewReplace) - End If - Loop until i = 0 - End If - ReplaceString = BigString + ReplaceString=join(split(BigString,OldReplace),NewReplace) End Function @@ -489,4 +453,5 @@ WRONGDATATYPE: Resume NoErr: End If NOERR: -End Function</script:module>
\ No newline at end of file +End Function +</script:module>
\ No newline at end of file |