mIRC Home    About    Download    Register    News    Help

Print Thread
#99247 30/09/04 12:35 AM
Joined: Apr 2003
Posts: 85
K
Babel fish
OP Offline
Babel fish
K
Joined: Apr 2003
Posts: 85
I was chatting on another website when it hit me ... why can't mIRC's Script Editor evaluate new script code before accepting changes? This sure would cut back on alot of infinate loops. I don't mean to use it as a spell/syntax checker but it should be at least smart enough to know when an endless loop will occur or anything else that could cause mIRC to instantly lock up or crash.

I know it's possible, Microsoft Excel does it when you click the save button.


--

katsklaw
Rather experienced Admin
Rather experienced mIRC Scripter
Amateur C Coder
Joined: Aug 2003
Posts: 314
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2003
Posts: 314
For solving problems such as endless loops mIRC would sometimes have to interpret lots of code, perhaps up until the point of executing all the code involved. For example, while (%globalvar != $null) with the statement calling a multitude of aliases. In one of these aliases may be the "end" of the loop, setting %globalvar to a value before returning to the statement so the loop can end. Is mIRC supposed to trace all this to alert you if a while loop is made correctly?

And I'm sure there are other more complicated cases that would require a lot of work on the processor's part to determine whether while condition/s is/are valid, a lot of jumping to and from scripts interpreting code and such. Other while statements such as while (%var !isnum) %var = $input(Enter number) or even while ($rand(1,100000000000) != 86) are perfectly valid, but could potentially make mIRC hang for a while. I think people are capable of checking their own code, and if their own loops jam mIRC they could break them with ctrl+break and try to fix the problem.

Edit: In response to the "anything else" part, if there was a feature that caused disruptive behavior in mIRC I'd think it would be corrected rather than simply cautioned

Last edited by Sigh; 30/09/04 06:47 AM.
Joined: Apr 2003
Posts: 85
K
Babel fish
OP Offline
Babel fish
K
Joined: Apr 2003
Posts: 85
Not sure about you .. but I would rather eat up a few seconds worth of CPU time everytime I saved a script than to have mIRC go into an endless loop and have to hunt for it. the CPU can find it thousands of times faster than I can.

What ever happened to the old fashioned saying of work smarter .. not harder?


--

katsklaw
Rather experienced Admin
Rather experienced mIRC Scripter
Amateur C Coder
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
That would probably be really hard to implement, recursion would be a problem, for example: an alias is called inside the while loop and there is no inc/dec %var inside it, so mIRC checks what the alias does, that alias calls the alias it checked first, so it goes back and forth, back and forth, obviously he could keep a list of aliases it's already checked, but it would be difficult to implement.

I wouldn't expect that sort of debugging unless he changes the script editor into a full IDE.


New username: hixxy
Joined: Dec 2002
Posts: 230
G
Fjord artisan
Offline
Fjord artisan
G
Joined: Dec 2002
Posts: 230
if you have an infinite loop running, just press ctrl+break, whats the problem?

Joined: Apr 2003
Posts: 85
K
Babel fish
OP Offline
Babel fish
K
Joined: Apr 2003
Posts: 85
The problem is the fact that the loop was allowed to happen in the first place.


--

katsklaw
Rather experienced Admin
Rather experienced mIRC Scripter
Amateur C Coder
Joined: Mar 2004
Posts: 111
Z
Vogon poet
Offline
Vogon poet
Z
Joined: Mar 2004
Posts: 111
well id say thats your problem :tongue:

The way i see it, mIRC does have an easy way of finding out if you have a potential unlimited loop. Save and Run it. :tongue:

If it freezes, well then you did somefin wrong :tongue:.

Personally i rarely have this problem, as with most people im sure. All you need to do is simply work around it, eg.
Code:
var %xs = 100
while (broken statement here) && (%xs > 0) {
more cappily coded junk here
dec %xs
}

And bam, your code will now not run forever. Ofcourse you change %xs to your needs, to 1k, 5k, 10k if needed, but none the less its a simple step to keep mirc from blowing up in your face.

Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
Even though "prevention is better than the cure", I don't think that statement applies here, you would have to use up cpu (probably a lot if you don't have a good computer) to check if the loop is broken, but then if the loop isn't broken then that cpu was a waste, it's a lot easier to leave it as it as and hit break when you run into one.

Besides, it's best to get a good understanding of loops before making one that will potentially crash your pc, even then you'll get the odd broken loop, but mainly from a typo or something silly like that.

If he does add this feature I think it should be optional and disabled by default.


New username: hixxy
Joined: Apr 2003
Posts: 85
K
Babel fish
OP Offline
Babel fish
K
Joined: Apr 2003
Posts: 85
I have a good undserstanding of mIRC scripting .. including loops. However, just like yourself and everyone else on this board I'm human .. which means that I am not perfect and subject to writing faulty code. So skill level is irrelivent.

Prevention is ALWAYS better than a cure .. regardless of situation.

I agree that it should be off by default .. infact I wouldn't want it to happen everytime I hit save. Perhaps it's best to have it as a button not unlike the braces eval button.


--

katsklaw
Rather experienced Admin
Rather experienced mIRC Scripter
Amateur C Coder
Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
The only infinite loops mIRC will be able to prevent are very simple logical errors. In order for it to be of any use at all mIRC would have to parse every script each time you changed a single peice of code anywhere at all since changing an alias could effect any loops that directly or indirectly call it. Parsing all scripts everytime you applied changes to your code would cause very noticeable lag. Seeing as 99.9999% of the time that someone applies changes to their code it won't cause an infiinite loop, it's extremely inefficient to have several seconds of lag (at least) each and every time it happens when an infinite loop can be stopped in a few seconds anyway as soon as the scripter realises what's happening.

So to sum up we'd end up with more wasted time in total from having mIRC check the code for infinite loops than we'd lose from just running them and ctrl+breaking. Not to mention that there are many many loops where mIRC simply couldn't tell whether it's an infinite loop or not.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Joined: Dec 2002
Posts: 208
H
Fjord artisan
Offline
Fjord artisan
H
Joined: Dec 2002
Posts: 208
I don't like the idea of it scanning on every save, but if Khaled were so inclined, simple error checking could maybe be done with a button, like the { } button in the script editor..


If I knew now what I will know then... maybe things will have been different...
Joined: Oct 2004
Posts: 2
O
Bowl of petunias
Offline
Bowl of petunias
O
Joined: Oct 2004
Posts: 2
i've written a very simple c++ compiler before, and i can tell you, detecting infinite loops in code is not an easy task at all. it is much better to let the programmer find his error through a lockup(ctrl + break it) than do all that extra work. Now it might be possible, with the mIRC scripting language to detect loops that are running the statements over and over again, but it still poses a problem. How many loops before it is considered an error? shoudl the language be limited to a max loop execution. to me the anwser is obvious, NO...


Link Copied to Clipboard