Need Advice on Finding My Missing { bracket

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
cleetz
Posts: 30
Joined: 04 Feb 2023, 15:09

Need Advice on Finding My Missing { bracket

Post by cleetz » 11 May 2024, 04:02

Hello. Ever since I can remember Ive had an issue with Skite4AHK where-in I'm missing a bracket somewhere, and its causing an opening bracket to attach to a closing bracket that it wasnt meant to attach to. I find myself wasting the most time out of any instance trying to find where the bracket is that I forgot to add. I dont have any method, I just scroll up and down for countless minutes seeing whats attached to what, trying to look through and see whats not connected to what. Does anyone have a method for quickly finding where the bracket is thats missing its counter-part? I feel like in my head I should intuitively know like delete one bracket somewhere and then whatever that bracket is now attached to was the one I'm missing or something, I just cant ever seem to grasp what to do. Thanks and appreciate any help.

User avatar
boiler
Posts: 17706
Joined: 21 Dec 2014, 02:44

Re: Need Advice on Finding My Missing { bracket

Post by boiler » 11 May 2024, 04:37

If you use a good indenting approach, it should make it easy to identify code blocks and quickly see where their associated pair of braces should be.

just me
Posts: 9783
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Need Advice on Finding My Missing { bracket

Post by just me » 11 May 2024, 05:22

Also, avoid the One True Brace (OTB, K&R style) because AHK 1.1 ignores such braces where not permitted.

User avatar
Chunjee
Posts: 1601
Joined: 18 Apr 2014, 19:05
Contact:

Re: Need Advice on Finding My Missing { bracket

Post by Chunjee » 11 May 2024, 09:13

Haven't had that problem since starting with VSC. Here is an interesting blog I came across while searching bracket pair colorization
Last edited by Chunjee on 11 May 2024, 17:59, edited 1 time in total.

User avatar
Chunjee
Posts: 1601
Joined: 18 Apr 2014, 19:05
Contact:

Re: Need Advice on Finding My Missing { bracket

Post by Chunjee » 11 May 2024, 09:13

Bet I could find it if the code was posted

User avatar
andymbody
Posts: 1034
Joined: 02 Jul 2017, 23:47

Re: Need Advice on Finding My Missing { bracket

Post by andymbody » 11 May 2024, 13:37

cleetz wrote:
11 May 2024, 04:02
Finding My Missing { bracket
Look between P and }. (Sorry... I had to...)
Chunjee wrote:
11 May 2024, 09:13
Bet I could find it if the code was posted
lol... would definitely help others participate in the search...
Does anyone have a method for quickly finding where the bracket is thats missing its counter-part?
You might try using regex search in Notepad++ to highlight matching pairs of braces. This would allow you to inspect to see if the grouping looks correct, and delete each legitimate find one at a time to narrow the search. This may or may not be helpful.
Here is the regex needle to plug in. It supports nesting as well.
(\{(?>[^}{]+|(?-1))*\})


if you have something like this, it may be very difficult to find. Especially with v1
(\d{2])

A script could be written to assist, but as Chunjee pointed out, posting the code will help others assist for a faster solution...

User avatar
Chunjee
Posts: 1601
Joined: 18 Apr 2014, 19:05
Contact:

Re: Need Advice on Finding My Missing { bracket

Post by Chunjee » 11 May 2024, 18:00

andymbody wrote:
11 May 2024, 13:37
Chunjee wrote:
11 May 2024, 09:13
Bet I could find it if the code was posted
lol... would definitely help others participate in the search...

No only I have been specifically trained for this. In fact my entire programming career has lead to this exact point. To find this exact missing curly boi

scriptor2016
Posts: 864
Joined: 21 Dec 2015, 02:34

Re: Need Advice on Finding My Missing { bracket

Post by scriptor2016 » 11 May 2024, 19:19

This is where I always thought that a text editor with color coding would come in handy.

I use Notepad++ for everything because I find it the easiest. You can color-code your text as well. Problem is, the color coding doesn't save with the file so next time you re-open your text file, the color coding is gone.

There's Sublime text editor which apparently has color coding but I find that program to be insanely complicated. Good old regular Notepad is just regular black text, so nothing there either.


If Notepad++ could save its colored text we'd have a winner there!



*Edit - Looks like Notepad++ may not actually change the text color by itself; it sort of adds a background color to it (looks the same as when regular text is highlighted, and it allows you to select the color of that highlighting)... but it doesn't change the color of the text. Which isn't too bad but then it can get confusing because someone might confuse that with the text actually being highlighted instead of it being just a color style. And again, it won't save this color-coding when closing the file and re-opening it later.

User avatar
boiler
Posts: 17706
Joined: 21 Dec 2014, 02:44

Re: Need Advice on Finding My Missing { bracket

Post by boiler » 11 May 2024, 21:58

scriptor2016 wrote: Good old regular Notepad is just regular black text, so nothing there either.

*Edit - Looks like Notepad++ may not actually change the text color by itself; it sort of adds a background color to it (looks the same as when regular text is highlighted, and it allows you to select the color of that highlighting)... but it doesn't change the color of the text.
Are you aware of the concept of syntax highlighting (the text color itself, not just the background) that pretty much every editor that is meant for coding, including Notepad++, is capable of? It automatically changes the color of the text depending on the category of the code (variables, function names, literal strings, comments, etc.)? Pretty much every major editor has an AHK-specific extension for highlighting per its syntax as well as many other language-specific features.

Notepad++ does indeed let you change the color of the text itself, btw. That’s what the AHK extensions for Notepad++ found here make use of when they implement syntax highlighting.

User avatar
andymbody
Posts: 1034
Joined: 02 Jul 2017, 23:47

Re: Need Advice on Finding My Missing { bracket

Post by andymbody » 11 May 2024, 22:49

Chunjee wrote:
11 May 2024, 18:00
No only I have been specifically trained for this. In fact my entire programming career has lead to this exact point. To find this exact missing curly boi
'Brace' yourself... life has no further purpose now...


Post Reply

Return to “Ask for Help (v1)”