mIRC Home    About    Download    Register    News    Help

Print Thread
Bracket mismatch location #226086 18/09/10 04:56 PM
Joined: Aug 2010
Posts: 134
T
Thels Offline OP
Vogon poet
OP Offline
Vogon poet
T
Joined: Aug 2010
Posts: 134
If you press Ctrl-H, while the number of open and close brackets don't match, mIRC will try to locate the location of the missing or excess bracket.

If you have more close than open brackets, it seems to pinpoint the problem correctly (which makes sense, since it's the location where mIRC would have to place the close bracket left of the screen).

However, if you have more open than close brackets, mIRC seems quite clueless, and most of the time sends me thousands of lines down, where I'm in a totally different part of my code.

Would it be possible to jump to the top of the function that has more open than close brackets? This should always be correctly pinpointable, since it's the last line where the even or alias is correctly aligned to the left side of the screen, whereas the bottom of the function depends on guesswork by mIRC.

This way you will always be located at the function that has the problem, instead of just anywhere in the rest of the code.


Learning something new every day.
Re: Bracket mismatch location [Re: Thels] #226089 18/09/10 06:55 PM
Joined: Oct 2003
Posts: 3,918
A
argv0 Offline
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
Err, how would it know? /alias is a command, so you can't just assume "a line beginning with 'alias'" is the start of an alias. ditto for events, since /on could be a command too (and /ctcp certainly is). Example:

Code:
alias myalias {
  if (%x == 2) {
    echo -a x is 2
}

alias /myotheralias /echo -a hi


This would be reindented as:

Code:
alias myalias {
  if (%x == 2) {
    echo -a x is 2
  }
  alias /myotheralias /echo -a hi
; missing } is here


As in, /myalias would create a new alias /myotheralias. This is a valid usage.

mIRC would complain that you're missing a } at the last line, and its guess would be as good as it could get. The above code is perfectly syntactically valid, and *COULD* have been what your intention was. It's impossible for mIRC to read your mind and tell where your alias is supposed to end if you don't tell it.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Re: Bracket mismatch location [Re: argv0] #226091 19/09/10 12:02 AM
Joined: Apr 2003
Posts: 342
M
MeStinkBAD Offline
Fjord artisan
Offline
Fjord artisan
M
Joined: Apr 2003
Posts: 342
Originally Posted By: argv0
Err, how would it know? /alias is a command, so you can't just assume "a line beginning with 'alias'" is the start of an alias. ditto for events, since /on could be a command too (and /ctcp certainly is). Example:

Code:
alias myalias {
  if (%x == 2) {
    echo -a x is 2
}

alias /myotheralias /echo -a hi


This would be reindented as:

Code:
alias myalias {
  if (%x == 2) {
    echo -a x is 2
  }
  alias /myotheralias /echo -a hi
; missing } is here


As in, /myalias would create a new alias /myotheralias. This is a valid usage.

mIRC would complain that you're missing a } at the last line, and its guess would be as good as it could get. The above code is perfectly syntactically valid, and *COULD* have been what your intention was. It's impossible for mIRC to read your mind and tell where your alias is supposed to end if you don't tell it.


Actually... if it worked it's way down... ran into a bracket mismatch... then worked it's way backup to the start of the mismatch... it would simply need to continue down again until it reached the alias "command" and flagged that as the cause of the mismatch, it would still be right well over 95% time.


Beware of MeStinkBAD! He knows more than he actually does!
Re: Bracket mismatch location [Re: MeStinkBAD] #226127 20/09/10 09:34 AM
Joined: Aug 2010
Posts: 134
T
Thels Offline OP
Vogon poet
OP Offline
Vogon poet
T
Joined: Aug 2010
Posts: 134
I'm not referring to "alias" specific.

For example, if my code in aliases.ini looks something like:

Code:
one {
  blah blah
  blah {
    blah {
      blah blah
      blah blah
    }
    blah blah
    blah blah
  }

  two {
    blah blah
    blah {
      blah blah
      blah blah
    }
    blah blah
    blah blah
  }

  three {
    blah blah
    blah {
      blah blah
      blah blah
    }
    blah blah
    blah blah
  }

  four {
    blah blah
    blah {
      blah blah
      blah blah
    }
    blah blah
    blah blah
  }


Now, as a human, it's pretty obvious that one is missing the } character, since two is the next function. Of course, mIRC has no clue that two would be the start of the new function, so it tries to guess where the missing } character is. From personal experience, I've found mIRC jumping down far into my code, like to the very end of the "three" function, though in practice it's often thousands of lines down.

My suggestion is that, instead of trying to determine the end of the faulty function, which is impractical for a logical process, jump to the start of the faulty function. That way, you're at least at the correct function, instead of practically anywhere in your code.

Finding the start of the faulty function should be easy, since that's the last line which is completely left aligned ("one {" in this case), whereas finding the end of the faulty function relies on a lot of guessing.

The thing is, about half the time it actually does jump to the top of the function. I haven't really been able to determine when it jumps to the top, and when it tries to jump to the bottom. The larger the script is, the greater the chance that mIRC searches for the bottom.


Learning something new every day.