Issue 97002 - bug in replace() function
Summary: bug in replace() function
Status: CLOSED DUPLICATE of issue 94895
Alias: None
Product: App Dev
Classification: Unclassified
Component: scripting (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: PC (x86_64) Windows XP
: P3 Trivial
Target Milestone: 4.2.0
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
: 97001 (view as issue list)
Depends on:
Blocks:
 
Reported: 2008-12-08 08:15 UTC by vladislav_yurov
Modified: 2016-04-19 07:48 UTC (History)
6 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
patch to fix this issue (1.53 KB, patch)
2009-01-06 07:29 UTC, pflin
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description vladislav_yurov 2008-12-08 08:15:02 UTC
Replace function work incorrectly when replaced fragment comes in source string 
more then once.

sub main
  msgbox replace("s p a c e s "," ","") ' "sp ce "
  msgbox replace("12223","2","xx") ' "1xxxx23"
end sum
Comment 1 kay.ramme 2008-12-08 09:03:10 UTC
Andreas, seems to be core BASIC, please have a look ...
Comment 2 kay.ramme 2008-12-08 09:04:36 UTC
.
Comment 3 ab 2009-01-05 14:17:11 UTC
ab->pflin: If I remember correctly you implemented the replace function.
As a reward ;-) you now also get the related issues. Please have a look.
We could integrate the fix into cws ab61.
Comment 4 pflin 2009-01-06 02:14:33 UTC
I will have a look
Comment 5 pflin 2009-01-06 07:29:16 UTC
Created attachment 59163 [details]
patch to fix this issue
Comment 6 pflin 2009-01-06 07:30:38 UTC
pflin -> ab, please have a look at the patch. if OK, please help commit into
your cws ab61
Comment 7 pflin 2009-01-06 08:41:26 UTC
seems this issue has been fixed since m37. It seems I have merged the patch into
cws pflin10. Need to verify.
Comment 8 ab 2009-01-19 15:30:22 UTC
Adding myself to CC as I got no notifications for this
issues after assigning it to pflin
Comment 9 salva 2012-07-06 19:26:58 UTC
Replace function work incorrectly  AOO 3.4 Spanish version in Windows Vista

Example

Sub Main
dim s as string, c as string
s = "SbxOBJECT addMetadataFile ( SbxSTRING, SbxARRAY )"
c = replace( s, "Sbx", "" )
msgbox c
End Sub

result: "OBJECT addMetadataFile ( SbxSTRING, SbxARRAY )"

Regards
Comment 10 Ariel Constenla-Haile 2012-07-07 02:22:35 UTC
(In reply to comment #9)
> Replace function work incorrectly  AOO 3.4 Spanish version in Windows Vista
> 
> Example
> 
> Sub Main
> dim s as string, c as string
> s = "SbxOBJECT addMetadataFile ( SbxSTRING, SbxARRAY )"
> c = replace( s, "Sbx", "" )
> msgbox c
> End Sub
> 
> result: "OBJECT addMetadataFile ( SbxSTRING, SbxARRAY )"
> 
> Regards

I couldn't find this function documented in the Online Help nor in the wiki Basic Guide.
Comment 11 hanya 2012-07-07 02:50:17 UTC
replace runtime function was introduced for compatibility with VBA by issue 85035. 
But it can be called without VBASupport on.
Comment 12 Ariel Constenla-Haile 2012-07-07 09:23:37 UTC
(In reply to comment #11)
> replace runtime function was introduced for compatibility with VBA by issue
> 85035. 
> But it can be called without VBASupport on.

Do you mean by setting Option Compatible on the module? or by some option in the Tools dialog?
Comment 13 hanya 2012-07-07 09:56:11 UTC
(In reply to comment #12)
> (In reply to comment #11)
> > replace runtime function was introduced for compatibility with VBA by issue
> > 85035. 
> > But it can be called without VBASupport on.
> 
> Do you mean by setting Option Compatible on the module? or by some option in
> the Tools dialog?
I needed to say, Option VBASupport 1 is not required to call replace runtime function. It works without loading Tools library.
Other functions introduced for compatibility reason like FormatDateTime, Round, InStrRev and StrReverse requires it on.
Comment 14 Ariel Constenla-Haile 2012-07-07 10:03:57 UTC
(In reply to comment #13)
> > Do you mean by setting Option Compatible on the module? or by some option in
> > the Tools dialog?
> I needed to say, Option VBASupport 1 is not required to call replace runtime
> function. It works without loading Tools library.
> Other functions introduced for compatibility reason like FormatDateTime,
> Round, InStrRev and StrReverse requires it on.

I see, then besides the bug that it does not work, there is the bug that it is not documented on the Online Help.
If I understood clearly, this is now a function of OO Basic Runtime Library, and so it should be documented as such.
Comment 15 damjan 2012-10-31 17:03:32 UTC
*** Issue 97001 has been marked as a duplicate of this issue. ***
Comment 16 damjan 2016-04-19 01:17:50 UTC
The test cases here work. This must have been fixed in #94895. Resolving duplicate.

*** This issue has been marked as a duplicate of issue 94895 ***