mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jun 2005
Posts: 44
B
BNX Offline OP
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Jun 2005
Posts: 44
I posted a problem in scripts section and some people didn't think it was possible without performing some crazy double-while pseudo code loop XD
Anyway, even then, it didn't seem to do what I needed, so I think this calls for an identifier request.

I have 12 variables:
%var.1 %var.4
%var.2 %var.5
%var.3 %var.6
and
%iable.1 %iable.4
%iable.2 %iable.5
%iable.3 %iable.6

There needs to be an easy way to check all of the variables with a similar name using a wildcard (in 1 function!)
like...
check if ANY of the %var.* variable values match up with ANY %iable.* variable values .
if (%var.* == %iable.*) is not possible...

so how about an identifier?
$chkall() // Check All ( variable with wildcard )

if ($chkall(%var.*) == $chkall(%iable.*)) { YAY }

Last edited by BNX; 30/07/05 08:49 AM.
Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
$chkall() is an identifier, it means it returns something. What should it return? Mind that identifiers do not know where they are called.

Maybe $chkall(% $+ var.* == % $+ iable.*) or $chkall(% $+ var.*,==,% $+ iable.*) could still stand a chance, but what should it return? Look for a matching pair? What about != ? Look for a not-matching pair? Or look for a matching pair and then return $false? What if there is no %var.* ?

You see, a lot of problems that would make this $identifier highly contested, you can script around it for those few uses it would be handy for, so I doubt Khaled would include something like this...

If you really really want such an identifier, here it is...
Code:
alias chkall {
  ; usage: $chkall(% $+ var.*,==,% $+ iable.*) returns $true if a matching pair exists
  ;        $chkall(% $+ var.*,!=,% $+ iable.*) returns $true if one pair matches this test
  ;                  -> $false only if ALL variables are the same...
  var %i = 1
  while ($var($1,%i)) {
    var %j = 1
    while ($var($3,%j)) {
      var %test = $iif( $var($1,%i).value $2 $var($3,%j).value , return $true)
      %test
      inc %j
    }
    inc %i
  }
  return $false
}

Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Really, the simplest way to do what you're asking is to change your script to make use of features/identifiers already in mIRC that are similar (but not the same) to what you're suggesting. Instead of using dynamic variables, use a hash table.

You could simply make two hash tables, var and iable, using a number for each item just like you are with the variables, and then use a simple loop like this:
Code:
var %i = 1
while $hget(var, %i) != $null {
  if $hfind(iable, $v1).data {
    [color:red]; A match has been found. Do something here[/color]
  }
  inc %i
}


This way the need for ugly embedded while loops is removed. $hfind() is fast, and a single while loop using it will be able to handle probably hundreds of items before it becomes noticeably slow.

Personally I think with hash tables and $hfind(), an identifier for variables like you're asking isn't really necessary. But then again what do I know, maybe a lot of people have been waiting for this.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
That loop can easily be implemented in script and has way too specific a use to see it being useful to many other people. I mean, how many times are you really going to check multiple variables against each other?

The answer is: not many, if you use a better method (the one suggested by starbucks)


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

Link Copied to Clipboard