offsides wrote:...because I want to search the whole string, and that's the default.
The same option applies to ReplaceString, and omitting a start there works fine.
Hi Bill. Both functions implement the start-position as an optional parameter,
but only when the parameter after it is not utilised.
In the case of the
FindString() function, in order to utilise the
Mode parameter, the
StartPosition parameter cannot be ignored. In your usage, the function is taking the constant value of
#PB_String_NoCase, which is 1 by the way, as the start position;
the mode has not been set.
Code: Select all
FindString(String$, StringToFind$ [, StartPosition [, Mode]])
The reason it worked with the
ReplaceString() function is because its parameter order is different; the
Mode comes before the
StartPosition. So, when you set the mode, the start position is not set, and essentially retains its default value.
Code: Select all
ReplaceString(String$, StringToFind$, ReplacementString$ [, Mode [, StartPosition [, NbOccurrences]]])
Accordingly, in order to utilise the 6th parameter
(number of occurrences) in the
ReplaceString() function, the start position must be set first.
To maintain the default values in such cases, the
#PB_Ignore directive could be used; like so:
Code: Select all
FindString(S$, "D", #PB_Ignore, #PB_String_NoCase)