-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
InStr() function missing parameters #263
Comments
Try, |
Maybe I didn't make it clear enough. The basic InStr function from AHK uses 5 parameters. I need that 5th parameter for occurrence. StrSplit only provides me a way to get the count of the last backslash in a file path, not the position of that backslash within the string. So it tells me there are X amount of backslashes which I want to use var.count() because it gives me the last occurrence. Then I use pos := InStr(File, "backslash", False, 1, var.count()) to get the position of that last backslash. My primary issue is that Ahk++ doesn't have the 5th parameter that AHK has by default. Does that make more sense? |
You have your
See example #3. And yes, the autocomplete is missing the 5th parameter. |
InStr(Haystack, Needle , CaseSensitive := false, StartingPos := 1, Occurrence := 1) ???? The filepath can be 100 characters long, if I run a StrSplit(File, "backslash") its only going to return 4 or 5 even though the last backslash is going to be maybe character number 70 in the string. Please run my example code, it will maybe give you clarity to what Im asking for. Regardless though, I can make this work in AHK Studio or Scite, its simply that Ahk++ doesn't pass through the occurence parameter all together. |
You have your File = "C:\Test\Test\Test.txt"
var := StrSplit(File, "\")
MsgBox % var.count()
pos := InStr(File, "\",False, var.count(), 1)
MsgBox % pos |
Scrap that.
|
Ahh... that was it the -1, well darn. I do believe the tab complete parameters in InStr() should be updated to include occurrence as of right now it only shows: InStr(Haystack, Needle [, CaseSensitive?, StartingPos]) Which is not all of the parameters. Was a simple oversight on my end, oh well ty! |
## 3.1.0 - 2022-11-21 🦃 Compiler: - New compiler options in settings: Choose base file, file icon, and "use [MPRESS](https://www.autohotkey.com/mpress/mpress_web.htm)" - Add "Compiler GUI" command in context menu to use the AHK GUI when compiling Snippets: - Update snippets for AHK 1.1.35.00 and fix broken `InStr()` snippet ([#263](#263)) Grammar: Fix `#Requires` not being recognized ([#268](#268)) Editor: New AHK file icon (green square with white H) Debugger: Minor debugger improvements Formatter: Close the following bugs: - Formatter incorrectly indents object literals ([#184](#184), [#222](#222)) - Nested one command code flow control ([#255](#255)) Miscellaneous: - Extension should start up faster
Description
When using InStr() function as the AHK documentation suggests, the AHK++ extension seems to have missed a parameter that is important to my code which is the occurrence parameter.
AHK Docs: InStr(Haystack, Needle , CaseSensitive := false, StartingPos := 1, Occurrence := 1)
AHK++ : InStr(Haystack, Needle [, CaseSensitive?, StartingPos])
Reproduction steps
Steps to reproduce the behavior:
Use AHK++ and try to set an occurrence parameter. Example code given below:
File = "C:\Test\Test\Test.txt"
var := StrSplit(File, "backslash")
MsgBox % var.count()
pos := InStr(File, "backslash",False, 1, var.count())
MsgBox % pos
Expected behavior
It should provide the character position in a string based on the var.count() result, which would be the last "" within the string's name.
Additional context
The text was updated successfully, but these errors were encountered: