Bug 132390 - BASIC: Replace's Start argument needs clarifying
Summary: BASIC: Replace's Start argument needs clarifying
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Documentation (show other bugs)
(earliest affected)
Hardware: All All
: medium normal
Assignee: Olivier Hallot
Whiteboard: target:7.0.0
Depends on:
Blocks: HelpGaps-NewFeatures
  Show dependency treegraph
Reported: 2020-04-24 22:08 UTC by Mike Kaganski
Modified: 2020-07-16 13:39 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Note You need to log in before you can comment on or make changes to this bug.
Description Mike Kaganski 2020-04-24 22:08:11 UTC
Replace's Start argument is documented in help [1] as "Numeric expression that indicates the character position within the string where the search shall begin. The maximum allowed value is 65535."

But it's not only that; it is also the start of the substring to be returned. This is how it's implemented, and also consistent with analogous VBA function [2].

E.g., Replace("ABCDE", "C", "*", 2) will return "B*DE", starting from the position 2. This needs to be documented in help.

[1] https://help.libreoffice.org/6.4/en-US/text/sbasic/shared/replace.html
[2] https://docs.microsoft.com/en-us/office/vba/Language/Reference/User-Interface-Help/replace-function
Comment 1 Mike Kaganski 2020-04-25 10:55:13 UTC
While at it, the argument has no limitation (or rather, it's 32-bit signed integer); the limitation of 65535 mentioned in help should be dropped.
Comment 2 Commit Notification 2020-04-29 12:59:22 UTC
Olivier Hallot committed a patch related to this issue.
It has been pushed to "master":


tdf#132390 Correction for replace() Basic function