mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
/if + %variables bug #87415 18/06/04 05:53 PM
Joined: Dec 2002
Posts: 266
Z
zack Offline OP
Fjord artisan
OP Offline
Fjord artisan
Z
Joined: Dec 2002
Posts: 266
The following will work just fine
Code:
//var %a 1,%b 2 | if %a < %b echo -a %b 


The following will not
Code:
//var %a 1,%b 2 | if %a < %b %b = 3 | echo -a %b


(Should give 2 Unknown command)

It's understandable that the if may still be trying to compare the two %b's and whatnot, but they're essentially the same code, yet the %b is treated as a command.


You won't like it when I get angry.
Re: /if + %variables bug #87416 18/06/04 06:04 PM
Joined: Dec 2002
Posts: 230
G
greeny Offline
Fjord artisan
Offline
Fjord artisan
G
Joined: Dec 2002
Posts: 230
If you do not use proper formatting you are bound to get errors like these...

//var %a = 1,%b = 2 | if (%a < %b) { %b = 3 } | echo -a %b

Re: /if + %variables bug #87417 18/06/04 06:07 PM
Joined: Dec 2002
Posts: 266
Z
zack Offline OP
Fjord artisan
OP Offline
Fjord artisan
Z
Joined: Dec 2002
Posts: 266
Sometimes proper formatting isn't enough. If one way works, the other should as well.


You won't like it when I get angry.
Re: /if + %variables bug #87418 18/06/04 06:22 PM
Joined: Dec 2002
Posts: 230
G
greeny Offline
Fjord artisan
Offline
Fjord artisan
G
Joined: Dec 2002
Posts: 230
Straight from the mIRC help file (/help /if):

Quote:
If an alias uses too few brackets then the statement might be ambiguous and the alias will take longer to parse, might be parsed incorrectly, or might not be parsed at all.

So, I wouldn't call this a bug.

Re: /if + %variables bug #87419 18/06/04 06:27 PM
Joined: Dec 2002
Posts: 266
Z
zack Offline OP
Fjord artisan
OP Offline
Fjord artisan
Z
Joined: Dec 2002
Posts: 266
Of course it's a bug. Either the first one is a bug, or the second one is. Because the literally same command does different things. I know it says that in the help file, but that doesn't mean it shouldn't be fixed.


You won't like it when I get angry.
Re: /if + %variables bug #87420 18/06/04 06:28 PM
Joined: Dec 2002
Posts: 230
G
greeny Offline
Fjord artisan
Offline
Fjord artisan
G
Joined: Dec 2002
Posts: 230
If you think "echo -a %b" and "%b = 3" is the same command...

Why not just use proper formatting and forget about all these "problems"?
I rather have a few brackets more and have my script work all the time instead of having a 50/50 chance of it working...

Re: /if + %variables bug #87421 18/06/04 06:34 PM
Joined: Dec 2002
Posts: 266
Z
zack Offline OP
Fjord artisan
OP Offline
Fjord artisan
Z
Joined: Dec 2002
Posts: 266
Because if you've ever done a challenge to create the smallest code, you'd feel the same way.

Edit: And yes, they are both commands.


You won't like it when I get angry.
Re: /if + %variables bug #87422 18/06/04 06:43 PM
Joined: Dec 2002
Posts: 230
G
greeny Offline
Fjord artisan
Offline
Fjord artisan
G
Joined: Dec 2002
Posts: 230
Well I still hope Khaled will fix the more important bugs rather than working on a guessing engine for people not willing to use brackets :P

Re: /if + %variables bug #87423 18/06/04 07:02 PM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Probably it's a bug that the variable assignment isn't recognised. However your reasoning for why you can't use a workaround is silly. Smallest code competitions are possibly the stupidest things ever. Nowhere in any other form of coding is making something small at the cost of extremely low readability considered to be a good thing. Perhaps with the exception of certain Perl zealots *pauses for jeers*.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Re: /if + %variables bug #87424 18/06/04 07:29 PM
Joined: Dec 2002
Posts: 266
Z
zack Offline OP
Fjord artisan
OP Offline
Fjord artisan
Z
Joined: Dec 2002
Posts: 266
Not entirely. Smallest code challenges are quite good in showing off your skills, that's why they're challenges in the first place. And it's a VERY good way to find lots of mIRC bugs and limitations. You'd be surprised how many bugs have been found through these little challenges.


You won't like it when I get angry.
Re: /if + %variables bug #87425 18/06/04 07:32 PM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Quote:
Smallest code competitions are possibly the stupidest things ever.


I'll have to agree, at least the way these competitions have been done so far. I really don't see the point in making the code ugly as hell and testing the parser's tolerance just to save a few bytes. Many of the submissions in such competitions don't even work in the next version of mirc because they rely on quirks, undocumented things and behaviours prone to change.

That doesnt' mean that smallest code shouldn't be part of the competition at all. Between two scripts that work equally well (which means they're equally correct, fast and stable), most people would prefer the smaller one. But smallest code being the only objective is pointless. Fastest code competitions would be much more meaningful, for one.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Re: /if + %variables bug #87426 18/06/04 08:13 PM
Joined: Jun 2003
Posts: 5,024
M
Mentality Offline
Hoopy frood
Offline
Hoopy frood
M
Joined: Jun 2003
Posts: 5,024
-General reply-

Heh, I think challenges are there to be just a little bit of fun...IRC isn't all abuse, seriousness and politics you know. Sure it tests scripter's abilities, but it's not meant to be some form of the Olympic Games, nor is it meant to be a challenge to find out who can create the best script ever...just a bit of fun for people to do if they are bored. A lot of the time, people who script say they don't know what to work on for their next project - well, whilst their thinking, they can have a go at the challenge, or other activities that various websites provide.

If there is a bug in mIRC and someone takes the time to report it, then leave Khaled to take notice of it and fix it if feasible. If workarounds are suggested, then the person who reported the bug should be thankful to the person or people that provided that workaround and use it, or put up with whatever is causing them inconvenience for the time being.

Regards,


Mentality/Chris
Re: /if + %variables bug #87427 18/06/04 08:22 PM
Joined: Mar 2004
Posts: 130
T
tsoglanos Offline
Vogon poet
Offline
Vogon poet
T
Joined: Mar 2004
Posts: 130
It`s not a bug, it`s a feature:

first i argge with you small code
but you script is buggy
the are two ways to make the code

way 1:
if (%x < 10) goto next

wav 2:
if %x < 10 { goto next }


1:
//var %a = 1,%b = 2 | if (%a < %b) %b = 3 | echo -a %b
2:
//var %a = 1,%b = 2 | if %a < %b { %b = 3 } | echo -a %b

also this is not a bug you jus used the if-then-else wrong

The ( ) brackets enclose comparisons, whereas the { } brackets enclose the commands you want to be performed if a comparison is true. You must make sure that the number of ( ) and { } brackets match to make sure that the correct comparisons are made, and that the correct commands are executed.

Re: /if + %variables bug #87428 18/06/04 08:37 PM
Joined: Dec 2002
Posts: 266
Z
zack Offline OP
Fjord artisan
OP Offline
Fjord artisan
Z
Joined: Dec 2002
Posts: 266
There's nothing wrong with the way I used my if-then-else statements. They're all valid.


You won't like it when I get angry.
Re: /if + %variables bug #87429 18/06/04 08:53 PM
Joined: Mar 2004
Posts: 130
T
tsoglanos Offline
Vogon poet
Offline
Vogon poet
T
Joined: Mar 2004
Posts: 130
zack if you are right next time dont use //var %a = 1, %b = 2
just use your way //var %a = 1 %b = 2
smile
.....

Re: /if + %variables bug #87430 18/06/04 11:09 PM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Indeed. A fastest code competition in a langauge like mIRC's also has an implicit nod towards small, clean code since typically a critical element to obtaining performance is of course to reduce the number of operations and the amount of parsing without making code ambiguous.

I think taking a relatively simple task and asking people to make the fastest code gives people a far greater chance to utilise some skill and is also far more enjoyable and practical. A good example I think was the thread in the Scripting Forum a while back with the $reverse identifier where throughout the thread we went through about half a dozen different implementations and algorithms, getting faster each time until the final solution worked out many times faster than the code that you'd traditionally see used to reverse text.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Re: /if + %variables bug #87431 19/06/04 07:17 AM
Joined: Dec 2002
Posts: 266
Z
zack Offline OP
Fjord artisan
OP Offline
Fjord artisan
Z
Joined: Dec 2002
Posts: 266
Indeed, "fastest" challenges are good in themselves, but also don't work for all instances. And even fastest challenges will make the user go beyond what's the norm and try and make the code as efficient as possible, even breaking what I wanted in my first post. Such as doing while something { } instead of while (something) { } and various other ways.

In the end, challenges are there to be... well... challenging To test what your skills can and can't do. Smallest code challenges do this, and many people like seeing how a rather large problem can fit into a 100 byte code. Because there's a lot of nice tricks you can do with mIRC Scripting, and still, a lot of limitations.

I was simply asking for one bug/limitation that works in once case, work in the other. But it seems a group of people would rather go out of their way to flame what even many of the top scripters do themselves, challenges, especially smallest code ones.

Also, I didn't ask Khaled to put this as his number one priority, I couldn't really care less if it wasn't fixed for 6 versions. I was simply reporting a bug that I found which I thought this board was for

I didn't want this to start into some big debate about the requirement for specific challenges, I was simply stating what was in my first post. This is, after all, the bug reports board, and it is indeed a bug.


You won't like it when I get angry.
Re: /if + %variables bug #87432 19/06/04 10:41 AM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Quote:
Such as doing while something { } instead of while (something) { }
This is definitely not beyond the norm, as item #140 of v5.4 versions.txt explains.


Quote:
I didn't want this to start into some big debate about the requirement for specific challenges
It's a forum, discussions are made and threads get a bit off-topic all the time. This is not something you can (or should) control. We know that you simply reported a bug and we also know that if you don't want to be part of the "big debate", you can happily ignore the thread (which you could have done after your first post) smile Oh, and I'm sure nobody's intention is to flame (although starbucks_mafia's wording was a little bit too "sincere" :tongue:), we're just discussing about related mirc subjects.







/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Re: /if + %variables bug #87433 20/06/04 10:53 AM
Joined: Dec 2002
Posts: 4,864
Khaled Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 4,864
The real issue is that I shouldn't have allowed the use of if-statements without () brackets in the first place.

The programming languages I've seen require the use of brackets in if-statements, and the reason is simple: without brackets, it is often difficult for the parser to know which values in an if-statement are part of the comparison. That's why it is important, as the help file states, to use () and {} in if-statements to make it clear what you are trying to do.

I have actually considered making the parser require the use of () (just like perl and C, and {} as well) in newer versions of mIRC but that would break all existing scripts.

Re: /if + %variables bug #87434 20/06/04 07:22 PM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
I, for one, am glad that you aren't making () required. I've found that if you always use {}, ()'s aren't necessary, unless of course you want to specifically alter the order of evaluation of conditions. I've found (from the countless /if statements I've written till now) that with the usage of {} only, the parser works correctly in 100% of the cases.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Page 1 of 2 1 2