mIRC Home    About    Download    Register    News    Help

Print Thread
#59436 07/11/03 11:31 PM
Joined: Nov 2003
Posts: 1
G
Mostly harmless
OP Offline
Mostly harmless
G
Joined: Nov 2003
Posts: 1
Will the For Next Loop, Do While Loop ever be added to mirc scipting ?

Thanks
Greystone

#59437 08/11/03 10:12 AM
Joined: Feb 2003
Posts: 309
C
Fjord artisan
Offline
Fjord artisan
C
Joined: Feb 2003
Posts: 309
Ugh. Already mirc script is sadly an organically grown thing without standard features between common comamnds (Some support say negative inputs which do something you'd expect, others don't, others still want strings where it makes little sense)
Its vaguely C like; but only in the vaguest of vaugeness.

Yet you want to take a visual basic (UGGGGHHH) approach to things?

For now; use this instead.

var %i = 0
var %MAX = 10
while (%i < %MAX) {
;do stuff
inc %i
}

or

var %boolean = $true
while (%boolean) {
if (condition == condition) { unset %boolean }
else {
;Stuff
}
}

Perfectly adequate solutions without messing around with the feel of the language

#59438 10/11/03 11:46 AM
Joined: Dec 2002
Posts: 266
Z
Fjord artisan
Offline
Fjord artisan
Z
Joined: Dec 2002
Posts: 266
DO WHILE loops are non-guarded (post-test loops), so they're completely inefficient, aka completely useless.


You won't like it when I get angry.
#59439 10/11/03 12:00 PM
Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Huh? There are plenty of situations where a Do...While loop is the practical method to do something. It's because it doesn't check conditions until one iteration which makes it useful in those situations. I think the fact that Do...While loops exist in the majority of programming and scripting languages is proof enough that they're not completely useless.

That said, there's no real necessity for them in a scripting language like mIRC's, I wouldn't really mind if they were added or not.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
#59440 10/11/03 12:11 PM
Joined: Dec 2002
Posts: 266
Z
Fjord artisan
Offline
Fjord artisan
Z
Joined: Dec 2002
Posts: 266
Yes I agree, and after thinking about it for a few minutes there have been cases where I've used them myself. But the fact still remains that they are significantly inefficient compared to a simple WHILE/FOR loop, especially when used on volume load projects.


You won't like it when I get angry.
#59441 10/11/03 02:59 PM
Joined: May 2003
Posts: 161
A
Vogon poet
Offline
Vogon poet
A
Joined: May 2003
Posts: 161
in c, and in perl, a do while loop is actually faster than a regular while.

#59442 10/11/03 07:33 PM
Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
(and a reply to Ashkrynt)

I don't see how a Do...While loop can be called faster, slower, or less efficient than a While/For loop, they all have their place where they're the most effective. When you need something to be performed at least once regardless of any conditions then a Do...While loop will be better all round than hacking it together with a While loop, and of course the reverse is true when you always want the condition to be checked first.


Spelling mistakes, grammatical errors, and stupid comments are intentional.

Link Copied to Clipboard