Hi. I think the number two is the position from the beginning of the string and then it would be fine.
Another example:Code: QB64: [Select]
s$ = "one two three four five six seven eight nine ten" PRINT s$ 'PRINT LEFT$(s$, find - 1)
EDIT: liked the slippery slope version better
I'd like you gentlemen to please adjust your expectations. Especially considering that the wiki article is still being written, as pointed out above.
With the exception of the last case stated in the list contained in https://www.techonthenet.com/excel/formulas/instrrev.php (https://www.techonthenet.com/excel/formulas/instrrev.php) (under the header "Example (as VBA Function)"), the behavior of the new function is expected to work as described in the link I now share.
Fellippe.
In the link I just shared there's a use for a negative value (-1 specifically, but I didn't bother not generalize). I'll let you have a look first.
Code: QB64: [Select]
my$ = "tom jane fred lois dog cat mouse tom jerry mouse" t& = InStringReverse&(t&, my$, "tom") PRINT t& ps& = ps& - 1 InStringReverse& = ps&
If start is null, the INSTRREV function will return #Error.4. why INSTRREV must return 0 if Start is greater StringMatch ?
StringMatch
String
Required. String expression being searched for.
Start
Int32
Optional. Numeric expression setting the one-based starting position for each search, starting from the left side of the string. If Start is omitted then -1 is used, meaning the search begins at the last character position. Search then proceeds from right to left.
Here my questions
1. the parameter Compare% is implemented in QB64 _INSTRREV?
2. What have I missed to understand only half of the example that is here https://www.techonthenet.com/excel/formulas/instrrev.php ?
3. what is the difference between Start = 0, Start = null and Start omitted in QB64?
Quote
If start is null, the INSTRREV function will return #Error.
4. why INSTRREV must return 0 if Start is greater StringMatch ?
_INSTRREV (Start%, WheretoSearch$, WhattoSearch$ )if WheretoSearch$ Is " a l p h a b e t " and Start% = 1
If there is a simpler way. I'm all ears, but this it what I came up with for now...
Then run that on everyone else's computer. Or don't ever share code.
Of course, nothing to stop anyone.
It's an open source project after all. It's not even mine.
That also gets me thinking, why didn't you patch the repo yet? What's stopping you if everyone is for the change of the new command?
The INSTR function searches for the first occurence of a search STRING within a base string and returns the position it was found.
position% = INSTR([start%,] baseString$, searchString$)
The _INSTRREV function searches for a substring inside another string, but unlike INSTR it searches from right to left.
position% = _INSTRREV([start%,] baseString$, subString$)
I have never used _INSTR() or INSTREV() before, but if this is an issue of consistency, I would highly recommend going for consistency in the functions, even if it means some current programs will break as a result.
After a decade of using PHP, I can say by far the worst part of it for me is the entirely inconsistent functions! Some function names have the modifier at the end, some at the start. Functions that are mirrors of each other have parameters in the opposite order, etc. It's a giant ugly mess, and makes it far harder to learn the programming language than it needs to be. If you have "foo_on()" you should have "foo_off()" not "disable_foo()". Programmers in general have a focus to details and consistency, as is needed to be good at programming. Functions that don't operate as expected, or are not named as expected, are a burden. It takes you out of programming logic, instead forcing you to focus on remembering the inconsistencies.
The descriptions read:
-and-
These don't behave the same?
Because their descriptions say they do, and the function name with REV at the end indicates it is the same but reversed.
As much as I respect you, Pete, I'll tell you what I've told Steve all day: We have JUST released a new version of QB64 with a feature that's been added 10 months back, overtly talked about in this forum. This not the time to lobby for a change.
The way _INSTRREV works is the way it was designed to work 10 months back. Back then all sorts of discussion and concession would have been easier.
Right now what we have is a stable release being advertised everywhere I can and which works as indicated in the wiki, link in my previous post.Code: QB64: [Select]Adjusting your expectations here means accepting that a function that *didn't exist before* now exists and works as it's been explained. And you now have written yourself a nice function for your own use that does exactly what you expect it to. Just like codeguy has been doing for a while now too in this thread.
People will read the wiki and learn how the new feature works. And they'll either use it or not. We have features galore and not everyone uses all of them.
Can we please celebrate a new release and cut back on the clippiness?
Sure, member tempers flare on occasion, but that's mostly because people care a lot about the project. I'll take that over apathy, any day.