Bug 129436

Summary: Unclear documentation of InStr "Compare" parameter
Product: LibreOffice Reporter: Jim Avera <jim.avera>
Component: DocumentationAssignee: Not Assigned <libreoffice-bugs>
Status: NEW ---    
Severity: normal CC: himajin100000, olivier.hallot
Priority: medium    
Version: 7.0.0.0.alpha0+   
Hardware: All   
OS: All   
Whiteboard:
Crash report or crash signature: Regression By:

Description Jim Avera 2019-12-16 21:05:01 UTC
Description:
The documentation for Basic function "InStr" says

  "To avoid a run-time error, do not set the Compare parameter if the first return parameter is omitted."

What does "return parameter" refer to here?   

Probably the wording should be clarified to give the parameter's name (is it 'Start' ?) and not say "return" unless the parameter is passed by value.

Note: None of the parameters are documented to return anything, although they are passed by reference (since not declared 'ByVal').

Steps to Reproduce:
1. Search for "InStr" in the Help

Actual Results:
.

Expected Results:
.


Reproducible: Always


User Profile Reset: No



Additional Info:
Comment 1 Jim Avera 2019-12-16 21:06:11 UTC
Typo, meant "unless the parameter is passed by reference"
Comment 2 Jim Avera 2019-12-16 21:13:42 UTC
While fixing this, there are a couple of other improvements which could be made:

* Mention whether the first position of a string is 1 or 0.

* Show the result from the code example (currently it just lists the code without saying what the expected result is).
Comment 3 Olivier Hallot 2019-12-16 21:22:50 UTC
In the example of the Help page on InStr, if we ommit Start and define Compare, we get an error. E.g.

iPos = Instr(sInput,"c",0)

Thus I think the word "return" is misleading and should be removed.
Comment 4 Olivier Hallot 2019-12-16 21:31:38 UTC
(In reply to Jim Avera from comment #2)
> While fixing this, there are a couple of other improvements which could be
> made:
> 
> * Mention whether the first position of a string is 1 or 0.

Wrong. For the same example,

 iPos = Instr(4,"Office","f",0)

the result is 0 because the search starts at position 4 and 'f' occurs at 2 and 3. IOW, it will search 'f' in string 'ice'.

> 
> * Show the result from the code example (currently it just lists the code
> without saying what the expected result is).

Agree.
Comment 5 Olivier Hallot 2019-12-16 21:32:37 UTC
correction, string "ce".