mIRC Home    About    Download    Register    News    Help

Print Thread
A whole load of suggestions. #213432 27/06/09 12:00 PM
Joined: Jan 2009
Posts: 116
Knoeki Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Jan 2009
Posts: 116
I'll appologize in advance if I mention anything that is already there, I might have overlooked some stuff...

File handling
Now, I know there are already a load of identifiers and such for file/directory handling, but I'm missing something that will return the number of files in a directory, for example... would be nice to have that...

ANDOR comparing
I might be completely stupid here, because maybe || already counts as an AND/OR, but yeah. I'd like to be able to do |& comparing. I can't really think of an example right now, but there have been a few times where I wanted this...

Script editor features.
It'd be really nice to see some of the following features in the script editor:

- Syntax hilighting (I know there's a DLL, but native support would be better, imho.). All the better if we can change the colours, including the background.
- Being able to actually use tab for indenting, including being able to set the tab size, seeing as everyone has a different preference... I like a tab size of 3, most people 2, some others more.
- Maybe, but now I'm going a bit far, it would be nice to have realtime bracket matching, including parantheses and the likes, and a loop checker that warns for infinite loops...

Scriptmanager
just a little window that shows all loaded scripts, and making it able to load/unload them from there. Also a list with previously loaded scripts could be added.

With an extra command (something like /mrcinfo), we could have scripts pass a description and author to show up in the scriptmanager... for example:

Code:
on *:LOAD: {
   mrcinfo -d The super annoying automagical textcolour script.
   mrcinfo -a Somelamer3468
   /* further initialization here */
}


the -d switch is for the description, -a for the author.

this should not have to break any backwards compatibility, as the description could stay blank for any scripts that don't report this information.

Maybe, and again I'll say I might be going a bit far with this, it would be possible to have mIRC warn for confliciting aliases/events or so.


constructive criticism and request for details are appreciated, flames to /dev/null please. :_)


http://zowb.net

/server -m irc.p2p-network.net -j #zomgwtfbbq
(ssl on port 6697 and 7000)
Re: A whole load of suggestions. [Re: Knoeki] #213434 27/06/09 03:56 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Number of files in a dir
$findfile(<dir>,*,0,<depth>)

ANDOR comparing
if (condition1) || (condition2) || (conditionN) { executes if all or any of the conditions matched }

Syntax hilighting
I'd second this one only if it can be disabled and has customizable colors smile

Tab for indenting
mIRC will re-indent the code anyway on
1) change of the editor's tab
2) click on "check brackets"
3) reopening the editor
so why temporarily indent via TAB? I'd rather like the TAB key to put an actual $chr(9) char

Check for infinite loops
I doubt it's practically possible. Example:
Code:
; non-infinite loop
while ($fline(@window,somewildtext,1)) { dline @window $v1 }

; infinite loop
while ($fline(@window,somewildtext,1)) { echo -a dline @window $v1 }

; ??? (depends on what "myalias" will do - it could be calling deeper and deeper)
while ($fline(@window,somewildtext,1)) { myalias $v1 }

Script description and author
I wonder if/how these infos would be of use? For the scriptmanager only? As new properties for $script()?

Confliciting aliases/events
What's your definition of "conflicting"? Imho the override of an alias or command, and some event not triggering due to a previous event may well be intended.

...my two cents smile

Re: A whole load of suggestions. [Re: Horstl] #213437 27/06/09 06:06 PM
Joined: Jan 2009
Posts: 116
Knoeki Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Jan 2009
Posts: 116
Originally Posted By: Horstl
Number of files in a dir
$findfile(<dir>,*,0,<depth>)


cool, didn't know that, will try it out soon :_)

Quote:
ANDOR comparing
if (condition1) || (condition2) || (conditionN) { executes if all or any of the conditions matched }


yeah, I figured... just wasn't sure.. :_)

Quote:
Syntax hilighting
I'd second this one only if it can be disabled and has customizable colors smile


disabling would definately be nice, not everyone likes it.

Quote:
Tab for indenting
mIRC will re-indent the code anyway on
1) change of the editor's tab
2) click on "check brackets"
3) reopening the editor
so why temporarily indent via TAB? I'd rather like the TAB key to put an actual $chr(9) char


I always indent my code as I type it. for now I have to press 3 spaces, because tab just goes to the cancel (or is that the Okay(?)) button.


Quote:
Check for infinite loops
I doubt it's practically possible. Example:
Code:
; non-infinite loop
while ($fline(@window,somewildtext,1)) { dline @window $v1 }

; infinite loop
while ($fline(@window,somewildtext,1)) { echo -a dline @window $v1 }

; ??? (depends on what "myalias" will do - it could be calling deeper and deeper)
while ($fline(@window,somewildtext,1)) { myalias $v1 }



yeah, I already found it hilighly unlikely, I don't really see the need anyway... just wrote it down in my train of thought.

Quote:
Script description and author
I wonder if/how these infos would be of use? For the scriptmanager only? As new properties for $script()?


mainly for the scriptmanager, I guess, although I won't hold anyone back to do whatever they want with it ;_) it's just nice to have such a thing in the scriptmanager (if there were one), since some scripts have fairly cryptic filenames at times.. a description can be helpful. XChat offers this functionality as well for a few script languages, as far as I know.


Quote:
Confliciting aliases/events
What's your definition of "conflicting"? Imho the override of an alias or command, and some event not triggering due to a previous event may well be intended.


good point. with conflicting I'd mean 2 aliases that have the same name (/test for example) that do different things.

But yes, it's also just a matter of 'needing it'... which I don't. As I said before, train of thought, etc. ;_)

thanks for the feedback! :_)


http://zowb.net

/server -m irc.p2p-network.net -j #zomgwtfbbq
(ssl on port 6697 and 7000)
Re: A whole load of suggestions. [Re: Knoeki] #213438 27/06/09 06:34 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Quote:
I'd mean 2 aliases that have the same name
the function would have to be able to discriminate between aliases that are global and have the same name to aliases that are local.

While a local alias is restricted to being called from the specific script that it's part of (same remote), global aliases can be called from any remote or even the command line.

While being able to quickly tell if there was 2 or more global aliases that have the same name (which is what it looks like you're suggesting), it wouldn't matter for local aliases.

A suggestion of my own, similar to this, is the ability to make groups local or global or a function to warn you if you are making a group that already exists in a loaded script. (P.S.: My apologies for adding a suggestion to your post, rather than making one of my own.)

Right now groups default as global, and therefore if you have two or more groups with the same name, when you enable/disable the group, you get all of the groups with that name.

Re: A whole load of suggestions. [Re: RusselB] #213440 27/06/09 07:51 PM
Joined: Jan 2009
Posts: 116
Knoeki Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Jan 2009
Posts: 116
Hey, no problem... as I said in my first post, suggestions are welcome, even completely new ones ;_)


http://zowb.net

/server -m irc.p2p-network.net -j #zomgwtfbbq
(ssl on port 6697 and 7000)
Re: A whole load of suggestions. [Re: Horstl] #213441 27/06/09 08:37 PM
Joined: Oct 2003
Posts: 3,918
A
argv0 Offline
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
Checking infinite loops may not be a hard science, but you could use a script loop check similar to the way browsers work these days, with an alert dialog popping up after considerable time saying "This script is running slowly, should I stop it?"-- this would probably be quite helpful to those unaware of ctrl+break.

mIRC could actually take advantage of the nature of the program to echo "You have a slow running script press CTRL+BREAK to stop it" in the active window (force a display update) instead of using an alert dialog, if it wanted.

The main problem with infinite loops is that users are unaware of the key combination to break out of them. mIRC could implement feasible solutions that have already been proven to help.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Re: A whole load of suggestions. [Re: argv0] #213460 28/06/09 12:31 PM
Joined: Jan 2009
Posts: 116
Knoeki Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Jan 2009
Posts: 116
great idea, argv0 :_)

another thing that I found, which may or may not be a feature, is that the following will crash:

Code:
var -u5 %x 1
while (%x == 1) {
   noop
}


now, this might be a bad example, but the point is, why can't we do while loops that loop infinitely, until a variable is unset, as per example, or when an identifier changes value? maybe I want to have something loop for 5 seconds...


http://zowb.net

/server -m irc.p2p-network.net -j #zomgwtfbbq
(ssl on port 6697 and 7000)
Re: A whole load of suggestions. [Re: Knoeki] #213461 28/06/09 01:19 PM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
When mirc is inside a loop, it doesn't do anything else apart from the commands specified in the loop body. This "anything" includes checking for timer events, either generated through /timer or through /set -u. This is a fundamental aspect of how mirc works and not likely to change.

Keeping mirc spinning in a loop for an X number of seconds is possible but is just bad practice. You can achieve the same effects by using timers and/or events.

Sidenote: what happens with example code you gave is usually referred to as freeze, not crash. The latter means the program does something unintended and as a result is shut down by Windows. Also, the example should use /set -u: /var doesn't have a -u switch (because -u doesn't really make sense for local variables given the above).

Last edited by qwerty; 28/06/09 01:21 PM.

/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Re: A whole load of suggestions. [Re: Knoeki] #213463 28/06/09 02:00 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Though a bit off topic a further method: pause snippet by FiberOPtics
...and a condensed version of it (without the syntax-, version-, OS-check): /compause <N in ms>
Code:
alias compause {
  var %wsh = wsh $+ $ticks
  .comopen %wsh wscript.shell
  .comclose %wsh $com(%wsh,run,1,bstr*,% $+ comspec% /c pathping.exe -n -w 1 -q 1 -h 1 -p $&
    $iif($1 > 40,$calc($1 - 40),$1) 127.0.0.1 >nul,uint,0,bool,true)
}
It's main use may be to insert pauses where a *lot of* computing occurs - to break some nasty freeze. For plain delays you'd better use timers.

Re: A whole load of suggestions. [Re: qwerty] #213474 28/06/09 08:09 PM
Joined: Jan 2009
Posts: 116
Knoeki Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Jan 2009
Posts: 116
Originally Posted By: qwerty
When mirc is inside a loop, it doesn't do anything else apart from the commands specified in the loop body. This "anything" includes checking for timer events, either generated through /timer or through /set -u. This is a fundamental aspect of how mirc works and not likely to change.


ah, I see. At least I know how that works then ;_)

Sidenote: what happens with example code you gave is usually referred to as freeze, not crash.[/quote]

You're absolutely right, I don't know why I mixed that up...

Quote:
Also, the example should use /set -u: /var doesn't have a -u switch (because -u doesn't really make sense for local variables given the above).


Haha, good point. With all the mistakes in my previous post, it makes me wonder if I was even awake when I wrote it :_D


http://zowb.net

/server -m irc.p2p-network.net -j #zomgwtfbbq
(ssl on port 6697 and 7000)
Re: A whole load of suggestions. [Re: Knoeki] #213475 28/06/09 08:32 PM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
I am my own infinite loop checker. If we had a machine to wipe our bottoms, what would we do when the electricity went out?

If you want the script editor to indent your code, press the {} button.

Originally Posted By: Knoeki
great idea, argv0 :_)

another thing that I found, which may or may not be a feature, is that the following will crash:

Code:
var -u5 %x 1
while (%x == 1) {
   noop
}


now, this might be a bad example, but the point is, why can't we do while loops that loop infinitely, until a variable is unset, as per example, or when an identifier changes value? maybe I want to have something loop for 5 seconds...


That is a paradox. A while loop either loops infinitely or it stops at a certain point.

Your code is a bad idea. Try this.

set -u5 %xy $true
while(%xy) {
do commands
}

But, as mentioned, there are better ways to handle this sort of thing.

Re: A whole load of suggestions. [Re: DJ_Sol] #213478 28/06/09 09:23 PM
Joined: Jan 2009
Posts: 116
Knoeki Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Jan 2009
Posts: 116
Originally Posted By: DJ_Sol
I am my own infinite loop checker. If we had a machine to wipe our bottoms, what would we do when the electricity went out?


I wrote it down in my train of thought, and someone even made a better suggestion, namely to warn a user that something is slowing down mIRC.

Quote:
If you want the script editor to indent your code, press the {} button.


As I said, I indent my code as I go. Now, I don't really use the scripteditor because it doesn't allow me to press tab and insert 3 spaces, I have to type them out manually. Automatic indenting uses (iirc) 2 spaces, wheras I want 3 of them, just to be really annoying ;_)


Quote:
That is a paradox. A while loop either loops infinitely or it stops at a certain point.


Sorry, I worded that wrongly then, you get my point.

Quote:
Your code is a bad idea. Try this.

set -u5 %xy $true
while(%xy) {
do commands
}


and this is different from my code... how? (other than /set, and as I pointed out already, I screwed up there.)


http://zowb.net

/server -m irc.p2p-network.net -j #zomgwtfbbq
(ssl on port 6697 and 7000)
Re: A whole load of suggestions. [Re: Knoeki] #213479 28/06/09 11:34 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
As identifiers are evaluated in every iteration, e.g.:
Code:
; /freeze <N in s>

alias freeze { 
  var %end = $calc($ticks + $$1 * 1000)
  while ($ticks < %end) { noop or code here }
}
Not that I can think of any use for it - apart from heating one's room with the CPU waste heat /freeze will cause... wink

Re: A whole load of suggestions. [Re: Horstl] #213482 28/06/09 11:54 PM
Joined: Jan 2009
Posts: 116
Knoeki Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Jan 2009
Posts: 116
Originally Posted By: Horstl
As identifiers are evaluated in every iteration, e.g.:
Code:
; /freeze <N in s>

alias freeze { 
  var %end = $calc($ticks + $$1 * 1000)
  while ($ticks < %end) { noop or code here }
}
Not that I can think of any use for it - apart from heating one's room with the CPU waste heat /freeze will cause... wink


I have folding@home to do that for me ;_) but thanks for pointing out.


http://zowb.net

/server -m irc.p2p-network.net -j #zomgwtfbbq
(ssl on port 6697 and 7000)
Re: A whole load of suggestions. [Re: Knoeki] #213546 30/06/09 11:51 AM
Joined: Jul 2008
Posts: 236
S
s00p Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Jul 2008
Posts: 236
This is going to be a long post. I thought I might stick up for khaled here, for a change. That's alot of work and it might actually wreck existing scripts, because if the events are set up to run on different threads then race conditions can be introduced. Yes, it would be cool to be able to do that, but it's not for everyone. If you're not careful some pretty scary bugs can pop up. I like the loop detection idea, but that would still be alot of work. In this case, mIRC appears to be entirely single-threaded, relying on non-blocking/asynchronous sockets. GUI stuff isn't much of a worry, because it rarely uses much CPU at all. That means when it runs into a blocking operation (e.g. a loop) that won't allow the GUI to update for a long time, things lock up like that). To make the change to run the script processing (all except user input), GUI processing and socket processing, on individual threads, can be a scary task for an application that is already quite well established. That's where mIRC would need to go, else risk possible race conditions. Maybe a better idea for things that could potentially lock up your mIRC looks like this:
Code:
alias qwerty {
  set -u5 %x 1
  asdf
}

alias asdf {
  ; loop condition
  if (%x != 1) {
    return
  }

  ; loop body
  noop

  ; loop jump/reset
  .timer -m 1 1 asdf
}


You could modify it, turn it into a post-test loop or add/remove a condition quite easily. You could speed it up by adding a loop that iterates 10 or 20 times at once before the function returns and allows socket/gui processing. Or you could just save files often, and be ready to press CTRL+BREAK, which is probably a good idea anyway.