mIRC Home    About    Download    Register    News    Help

Topic Options
#212074 - 10/05/09 11:19 AM Open script editor on error.
sparta Offline
Planetary brain

Registered: 22/02/03
Posts: 3432
Loc: Sweden/Borlänge
I was thinking of the script editor, mirc often show you the error, and also the line where the error occurred, how about open up the script editor, and at the same time highlight the line?

* /did: 'test' invalid id '2' (line 3, test.mrc)

and this would open up the script editor, and show me the line 3 in the dialog (just as an example i used a dialog), and make a option in the options dialog to enable/disable this feature? would save us some time to browse in the script editor to find the line you looking for. Just an idea i got. smile and yes, i know you can type in the line and jump down to it, but if it doing this itself it would go much faster.. smile
_________________________
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }

Top
#212077 - 10/05/09 03:45 PM Re: Open script editor on error. [Re: sparta]
The_JD Offline
Fjord artisan

Registered: 28/03/06
Posts: 392
Loc: New South Wales, Australia
Not really a good idea, unless it was optioned.
Many mIRC users would be confused if they were using a downloaded script and the script editor is popping up every 5 minutes.
_________________________
[02:16] * Titanic has quit IRC (Excess Flood)

Top
#212079 - 10/05/09 03:58 PM Re: Open script editor on error. [Re: The_JD]
sparta Offline
Planetary brain

Registered: 22/02/03
Posts: 3432
Loc: Sweden/Borlänge
As i wrote "and make a option in the options dialog to enable/disable this feature", and have it Disabled as default after install of mirc. And since mirc show you the line that feature already is there all that is needed is a call for the dialog, and that it show the right line, no need to highlight the line, just that it brows down to lets say 100 if the error is in line 110, then you are at the area of the problem from start. smile
_________________________
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }

Top
#212084 - 10/05/09 08:39 PM Re: Open script editor on error. [Re: sparta]
argv0 Offline
Planetary brain

Registered: 13/10/03
Posts: 3918
Loc: Montreal, QC, Canada
Even with the ability to disable it, it's still a pretty bad idea. This is equally annoying even for the script author. Imagine having broken code inside a fast timer. How would you disable it if you keep losing focus? Or something that triggers ON TEXT (potential social engineered DoS). Or maybe imagine that you're happily typing text while the script editor pops up and then you end up typing bogus crap into your script editor without noticing, adding *more* bugs to your already broken script. Popping up dialogs in your face without asking for it is something that's already been phased out of UI design for good reason, because it's annoying as sin.

The better idea would be to have HOTLINK behaviour and open the editor if you double clicked the filename, though that would require special hotlink support to differentiate a real filename from any "word.word".
_________________________
- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"

Top
#212085 - 10/05/09 08:55 PM Re: Open script editor on error. [Re: argv0]
sparta Offline
Planetary brain

Registered: 22/02/03
Posts: 3432
Loc: Sweden/Borlänge
* /did: 'test' invalid id '2' (line 3, test.mrc) <- How often do you type anything like that while scripting? and why type something sent to the status window while scripting? and if you can disable it, then you wont be dealing with that function in mirc. smile and as i said, it's just a idea..

And it should only trigger on error, nothing else..
_________________________
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }

Top
#212086 - 10/05/09 09:32 PM Re: Open script editor on error. [Re: sparta]
argv0 Offline
Planetary brain

Registered: 13/10/03
Posts: 3918
Loc: Montreal, QC, Canada
What do you mean, "how often"? It could happen extremely often.

It doesn't even need to happen "while scripting". Bugs, as you probably know, don't stop occurring when you decide to stop scripting. If you have various bugs in your script you could end up with such errors all over the place at any moment in time. You make the naive assumption that errors can only occur by direct input from the user-- this is wrong.

Anyhow, here's an idea for you. I fleshed out the HOTLINK script in the above post:

Code:
alias sendkeys { .comopen a WScript.Shell | .comclose a $com(a,SendKeys,3,*bstr,$$1-) }
on $^*:HOTLINK:/(\S+\.(mrc|ini))/:*: { 
  if (!$regex($hotline,\(line (\d+)\x2C $regml(1) $+ \)$)) halt
}
on $*:HOTLINK:/(\S+\.(mrc|ini))/:*:{ 
  var %filename = $regml(1)
  if ($regex($hotline,\(line (\d+)\x2C %filename $+ \)$)) {
    var %valid = $true, %index = 1, %type = R
    while ($script(%index)) { if ($v1 == $script(%filename)) goto open | inc %index }
    var %index = 1, %type = A
    while ($alias(%index)) { if ($v1 == $alias(%filename)) goto open | inc %index }
    %valid = $false
    :open
    dec %index
    sendkeys $+(%,R%,%type) 
    if (%valid) {
      .timer -m 1 100 sendkeys % $!+ V{DOWN %index $+ }~
      .timer -m 1 200 sendkeys ^G $+ $regml(1) $+ ~+{END}
    }
  }
}


Assuming the error is in a Remote script or Aliases but not Popups section, this should allow you to click the filename and load up the line, all highlighted and everything.
_________________________
- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"

Top
#212088 - 10/05/09 10:09 PM Re: Open script editor on error. [Re: argv0]
Horstl Offline
Hoopy frood

Registered: 03/11/06
Posts: 1559
Loc: Germany
While I don't regard the feature itself very useful, I tried that nice script instantly - but it failed for me:
having more remote scripts loaded than the "view" menu can show, it will open a wrong file. And I don't know how to access the "more..." option of the view menu with sendkeys (as it will have a variable no. of lines), to enter the script's name in the editbox of "more" and open the right file. smile

Edit: maybe a if ($script(0) > 25) { 26x DOWN = 1x UP in "view" } will do the trick.


Edited by Horstl (10/05/09 10:13 PM)

Top
#212093 - 10/05/09 10:20 PM Re: Open script editor on error. [Re: Horstl]
argv0 Offline
Planetary brain

Registered: 13/10/03
Posts: 3918
Loc: Montreal, QC, Canada
It would indeed help for mIRC to have a /command to load the script editor, possibly with an optional filename that could load that file (maybe even having line-number semantics, though it should not highlight the line), eg. /script -l28 file.mrc

If any feature is added from this suggestion, maybe it should be that. It would turn the above hotlink script into:

Code:
on $^*:HOTLINK:/(\S+\.(mrc|ini))/:*: { 
  if (!$regex($hotline,\(line (\d+)\x2C $regml(1) $+ \)$)) halt
}
on $*:HOTLINK:/(\S+\.(mrc|ini))/:*:{ 
  var %filename = $regml(1)
  if ($regex($hotline,\(line (\d+)\x2C %filename $+ \)$)) {
    script -l $+ $regml(1) %filename
  }
}
_________________________
- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"

Top
#212096 - 10/05/09 11:10 PM Re: Open script editor on error. [Re: argv0]
Horstl Offline
Hoopy frood

Registered: 03/11/06
Posts: 1559
Loc: Germany
Only for those who are both interested and as disorganised as I am (with more than 25 remotes and/or aliases loaded):
Here's a modification of argv0's script (from the 2nd hotlink event onwards). It uses the "more" dialog to open the "right" file for more than 25 files, and loops only aliases OR remotes.
Code:
on $*:HOTLINK:/(\S+\.(mrc|ini))/:*:{ 
  var %filename = $regml(1)
  if ($regex(line,$hotline,\(line (\d+)\x2C %filename $+ \)$)) {
    var %index = 1, %type = $iif($script(%filename),R,$iif($alias(%filename),A)), %more 
    if (%type == A) { 
      if ($alias(0) > 25) { var %more = $true }
      else {
        while ($alias(%index)) { if ($v1 == $alias(%filename)) goto open | inc %index }
      }
    }
    elseif (%type == R) { 
      if ($script(0) > 25) { var %more = $true }
      else {      
        while ($script(%index)) { if ($v1 == $script(%filename)) goto open | inc %index }
      }
    }
    else { return }
  }
  :open
  dec %index
  sendkeys $+(%,R%,%type)
  .timer -m 1 100 sendkeys % $!+ V $+($chr(123),$iif(%more,UP,DOWN %index),$chr(125),~)
  if (%more) { .timer -m 1 200 sendkeys $sendsafe(%filename) $+ ~ }
  .timer -m 1 300 sendkeys ^G $+ $regml(line,1) $+ ~+{END}
}

alias -l sendsafe { return $regsubex($1-,/(.)/g,$+($chr(123),\t,$chr(125))) }

Top
#212114 - 11/05/09 11:49 AM Re: Open script editor on error. [Re: Horstl]
Excalibur Offline
Vogon poet

Registered: 07/05/09
Posts: 139
Loc: FL, US
What is this supposed to trigger?
It doesn't trigger anything in these examples:
* /mode: not connected to server (line 1, saliases.ini)
-
* /dialog: invalid parameters (line 275, aliases.mrc)
-
* /did: 'test' invalid id '2' (line 3, test.mrc)
_________________________
- Excalibur
- Good and Evil, there never is one without the other.

Top
#212116 - 11/05/09 03:25 PM Re: Open script editor on error. [Re: Excalibur]
Horstl Offline
Hoopy frood

Registered: 03/11/06
Posts: 1559
Loc: Germany
Originally Posted By: Horstl
Here's a modification of argv0's script (from the 2nd hotlink event onwards).
I provided only the code parts I altered/added, it won't work without this part (sendkey alias and first hotlink event):
Code:
alias sendkeys { .comopen a WScript.Shell | .comclose a $com(a,SendKeys,3,*bstr,$$1-) }
on $^*:HOTLINK:/(\S+\.(mrc|ini))/:*: { 
  if (!$regex($hotline,\(line (\d+)\x2C $regml(1) $+ \)$)) halt
}

Also note that both scripts won't attempt to open the editor until you double-click the filename (something.mrc/-.ini) in the error message. You should see a different cursor icon if hovering over that part of that a line.

Top
#212119 - 11/05/09 08:20 PM Re: Open script editor on error. [Re: Horstl]
Excalibur Offline
Vogon poet

Registered: 07/05/09
Posts: 139
Loc: FL, US
*faceplam* heh sorry, didn't see this part
_________________________
- Excalibur
- Good and Evil, there never is one without the other.

Top