The Basic language "InStr" function is documented to have an optional initial argument giving the starting offset for searching. However any attempt to pass a number for the first argument raises an "Invalid Procedure Call" function.
Seems to be inherited from OO (occurs in LO 3.3)
Either this should be fixed, OR the documentation changed to say the 'start' argument is not supported by Libre Office.
To save the remaining hair on programmers' heads!
Here is the current (LO 7.x) documentation for the InStr function:
InStr ([Start As Long,] Text1 As String, Text2 As String[, Compare])
Start: A numeric expression that marks the position in a string where the search for the specified substring starts. If you omit this parameter, the search starts at the first character of the string. The maximum allowed value is 65535.
Text1: The string expression that you want to search.
Text2: The string expression that you want to search for.
Compare: Optional numeric expression that defines the type of comparison. The value of this parameter can be 0 or 1. The default value of 1 specifies a text comparison that is not case-sensitive. The value of 0 specifies a binary comparison that is case-sensitive.
To avoid a run-time error, do not set the Compare parameter if the first return parameter is omitted.
[So it must be intended to work by checking the type of the first argument to see if it is a string or a number]
Steps to Reproduce:
1. Start LO calc
2. Tools->Macros->Organize Macros->Basic
3. Navigate to the current document (e.g. "Untitled1", create a new module, and paste the following Basic code into the empty module:
Dim start as Long
start = 0
i = InStr(start, "abc", "b")
MsgBox "Succeeded, returned " & i
4. Place cursor inside the above function and click "Run" button on the toolbar
Popup says "Action not supported; Invalid procedure call"
Should work, or else be documented to not work.
User Profile Reset: No
I forgot to mention that ading the "Compare" argument does not make it work, so
InStr(0, "abc", "b", 0)
still raises the "Invalid Procedure Call" error
Build ID: 71a3f015f2ac45ad4a2625a3b6398f5d75feed40
CPU threads: 12; OS: Linux 5.4; UI render: default; VCL: gtk3;
TinderBox: Linux-rpm_deb-x86_64@86-TDF, Branch:libreoffice-6-4, Time: 2020-10-01_08:33:37
Locale: en-US (en_US.UTF-8); UI-Language: en-US
Ach! Never mind. Start counts from 1, not 0.
If you pass 0 you get "Invalid Procedure Call"
The function is clarified in 7.1 (tdf#136213):