mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jul 2008
Posts: 236
S
s00p Offline OP
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Jul 2008
Posts: 236
In any other language that allows negative numbers to be an inverse index for $left and $right, something like $right(a,-1) would return a. Is it intentional that mIRC returns $null in this case? This only seems to happen for strings where the length is 1.

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
From the help file
Quote:
If N is a negative value, it returns all but N characters.
Noting the bolded word, what you are noting is intentional.

1 - 1 = 0. I suppose Kahled could've made it return 0 rather than $null.

Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
In any other language (well, not any) the base index starts at 0. Is this also justification to change mIRC? Because mIRC starts indexes at 1 by convention, it makes sense for -1 to behave differently from the "other languages" you're referring to where the base is 0.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Joined: Jul 2008
Posts: 236
S
s00p Offline OP
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Jul 2008
Posts: 236
No, it's completely unrelated. What is -0 in any other language? They've gone through with the inconsistency of any non-zero index at all. What I'm complaining about is strange, and makes things difficult. The mere fact that it's strange behaviour to me makes it a bug in my mind.

I have another one for you. No use denying this one: $and(1111,16) == STUPID!

Last edited by s00p; 16/06/09 01:11 PM.
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
What is stupid about it?

Boolean AND Logic Table:

Code:

1 & 1 = 1
0 & 1 = 0
1 & 0 = 0
0 & 0 = 0



Therefore:

Code:

 1111d = 10001010111b
 0016d = 00000010000b
&--------------------&
         00000010000b = 0016d



-genius_at_work

Joined: Jul 2006
Posts: 4,144
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,144
What the point comparing to other language ?
As stated by the help file, when a negative value is used, it return all BUT N characters, then :

$right(abc,-1) return bc
$right(ab,-1) return b
Do you expect $right(a,-1) to return 'a' now ? This would make inconstistency.
Quote:
The mere fact that it's strange behaviour to me makes it a bug in my mind.
I don't call a strange behavior something that respect what the help file say.If you don't like the behavior it's another story, but to answer your question, yes the behavior is intentional.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jul 2008
Posts: 236
S
s00p Offline OP
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Jul 2008
Posts: 236
woah, duh. I really should think about what I write more often.

Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
I'm not sure what your comparison is. "They've gone through with the inconsistency" -- who is "they"? do you have an example where a language with a non-zero base index solves this problem?


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"

Link Copied to Clipboard