mIRC Homepage
Posted By: coolspot $ifmatch(N) - 11/01/04 07:33 PM
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 () && ()
Posted By: cold Re: $ifmatch(N) - 12/01/04 09:10 AM
This would be nice IMHO, I only hope it wouldn't slow things..
Posted By: Doqnach Re: $ifmatch(N) - 12/01/04 04:22 PM
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 ?
Posted By: Raccoon Re: $ifmatch(N) - 12/01/04 05:23 PM
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
Posted By: cold Re: $ifmatch(N) - 12/01/04 09:47 PM
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.
Posted By: starbucks_mafia Re: $ifmatch(N) - 12/01/04 11:04 PM
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).
Posted By: DaveC Re: $ifmatch(N) - 12/01/04 11:24 PM
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?)
Posted By: cold Re: $ifmatch(N) - 13/01/04 11:10 PM
I thought it could have a little impact.. well Khaled would know what's better, I hope.
© mIRC Discussion Forums