mIRC Home    About    Download    Register    News    Help

Print Thread
#67495 11/01/04 07:33 PM
Joined: Mar 2003
Posts: 50
C
Babel fish
OP Offline
Babel fish
C
Joined: Mar 2003
Posts: 50
It would be nice to have an N parameter for $ifmatch/

For example, lets say I have:
if (text isin sometext) && (text2 !isin sometext) { do stuff }

$ifmatch(1) would return "text"
$ifmatch(2) would return "text2"
$ifmatch(0) would return the number of comparison matches, in this case 2 because we have () && ()

#67496 12/01/04 09:10 AM
Joined: Feb 2003
Posts: 810
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Feb 2003
Posts: 810
This would be nice IMHO, I only hope it wouldn't slow things..


* cold edits his posts 24/7
#67497 12/01/04 04:22 PM
Joined: Jan 2003
Posts: 1,063
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2003
Posts: 1,063
but where is the point it stops counting ?

Code:
if (something) && (some other thing) {
  if (some entirely other thing) {
    echo something
  }
  if (something == some other thing) {
    echo something
  }
}


which would make 3, if you have big functions, it will pile-up fast!

where would it reset? at the end of the function/event ?


If it ain't broken, don't fix it!
#67498 12/01/04 05:23 PM
Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
Not to menton that you can nest identifiers in conditions, including $iif.

$ifmatch is a simple global variable. I don't think IF conditions even "see" eachother to know when such an array would have to be reset. All in all, I would imagine $ifmatch(N) would be more trouble than it's worth.

- Raccoon


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
#67499 12/01/04 09:47 PM
Joined: Feb 2003
Posts: 810
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Feb 2003
Posts: 810
It could be just like a named regex match list, as in $regml(). A limit of 10 items, and perhaps only local ones (personal opinion from one who thinks $ifmatch should be local - global ones would be fine as well, resembling $regml() even more). Doesn't sound confusing to me. The only thing I'd really worry about is speed.. and maybe this could be just another identifier, leaving $ifmatch as it is.


* cold edits his posts 24/7
#67500 12/01/04 11:04 PM
Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Well as far as I can tell he's only talking about it retaining the matches from the last if/$iif(), meaning it's hardly going to be a large amount to store.

cold: $ifmatch would naturally be kept for backwards compatability anyway. Even if it was slower using $ifmatch() I don't think it would have any impact on $ifmatch. I'd imagine they're treated separately (based on the fact that you can create and use aliases with the same name as built-in identifiers provided they don't take parameters if the built-in one does and vice-versa).


Spelling mistakes, grammatical errors, and stupid comments are intentional.
#67501 12/01/04 11:24 PM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
well the idea wouldnt be hard to implement
I beleive it would have to remain local, as a global $ifmatch.array(x) would suffer from defined identifiers having IF statments with in.

if it was local, you could do this.

(1) an If starts, clear the temp a TEMPifmatch.list
(2) process the conditions adding each valid ifmatch value to the TEMPifmatch.list
(3) if the if completes as valid then copy the TEMPifmatch list to the permenent $ifmatch.list dumping old ones off the front
or
(3b) if the if completes as valid then replace the ifmatch.list with the TEMPifmatch.list (if old match lists are ment to be lost each time)

The hardest thing would be if its easy or not to implement local identifiers, of the top of my head i cant think of any, so maybe they dont exist, or are hard to implement.

PS : i reread my idea, and have an inkiling feeling im missing some logicical problem with it, but cant seem to see it right now, so if its there, please excuse me. (maybe to do with $ifmatch being used in a IF?)

#67502 13/01/04 11:10 PM
Joined: Feb 2003
Posts: 810
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Feb 2003
Posts: 810
I thought it could have a little impact.. well Khaled would know what's better, I hope.


* cold edits his posts 24/7

Link Copied to Clipboard