mIRC Homepage
Posted By: s0tt0 Help with script (if elseif and variables) - 03/03/05 04:04 PM
Heres my script:
Code:
   if ($did(12).state == 1) {     
    if ($did(2, seltext) isalnum) {
      %g, %z, %r
      if ($did(8, seltext) isnum) { 
        set %r -r $did(8, seltext)
      }
      elseif ($did(6, seltext) isalnum) {
        set %g -g $did(6, seltext) 
      }
      elseif ($did(4, seltext) isalnum) {
        set %z -s $did(4, seltext) 
      }
      msg #mychannel !info %g %z %r $did(2, seltext)
    }
    else { 
      if ($did(2, seltext) isalnum) {
        msg #mychannel !info $did(2, seltext)
      }
    }
  } 

I want to make a script for all users in my channel, but I cant get it to work and i have problems with this code only. It should message an infoline in format !info -s <help section> -r <results> <searchstring> (e.g. !info -s channelhelp -r 10 i need help). It works but with only 1 paramater (if it shows -s then it wont show -r but i need them together and i have 5 parameters which you can use any way you like). Texts come from dialog boxes.. It's pretty confusing text but I'll hope someone will understand it and help me with it smile

TIA
s0tt0
Untested..

Code:
if ($did(12).state == 1) { 
  if ($did($dname,2).seltext isalnum) {
    %g, %z, %r
    if ($did($dname,8).seltext isnum) { 
      set %r -r $did($dname,8).seltext
    }
    elseif ($did($dname,6).seltext isalnum) {
      set %g -g $did($dname,6).seltext
    }
    elseif ($did($dname,4).seltext isalnum) {
      set %z -s $did($dname,4).seltext
    }
    msg #mychannel !info %g %z %r $did($dname,2).seltext
  }
  else { 
    if ($did($dname,2).seltext isalnum) {
      msg #mychannel !info $did($dname,2).seltext
    }
  }
} 
Posted By: s0tt0 Re: Help with script (if elseif and variables) - 03/03/05 06:11 PM
nop it doesnt work at all now. its not the did commands that are wrong but theres something with variables, becuse it doesnt display the variables alltogether
Post in the code that you have, dialog, sclicks, inits etc. See if we can unveil it.
Posted By: s0tt0 Re: Help with script (if elseif and variables) - 03/03/05 06:56 PM
rest of the code works 100% i have problems only with this one. maybe you cant do it with variables or something...
if ($did($dname,2).seltext isalnum) {
%g, %z, %r

There's your error.

This will evaluate the variable named "%g," to its value, and try to execute that value as a command, with the values of variables "%z," and "%r" as parameters passed to this supposed command.

10/1 says you don't have a variable named "%g," (that is with the comma in the name)

Greets
Posted By: s0tt0 Re: Help with script (if elseif and variables) - 03/03/05 09:13 PM
but still how can i fix it so it shows only those commands what i have chosen in dialog box from options?
Posted By: Iori Re: Help with script (if elseif and variables) - 04/03/05 09:49 PM
Code:
  if ($did(12).state == 1) {
    if ($did(2).seltext isalnum) {
      var %a
      if ($did(8).seltext isnum) { %a -r $v1 }
      if ($did(6).seltext isalnum) { %a %a -g $v1 }
      if ($did(4).seltext isalnum) { %a %a -s $v1 }
      msg #mychannel !info %a $did(2).seltext
    }
  }
  else {
    if ($did(2).seltext isalnum) { msg #mychannel !info $v1 }
  }
Posted By: s0tt0 Re: Help with script (if elseif and variables) - 05/03/05 09:35 AM
hmm i cannot understand some part of this script you gave me, what are those $vl for?
Posted By: Iori Re: Help with script (if elseif and variables) - 05/03/05 10:02 AM
It's all in the help file. /help $v1
  • If-then-else statements

    The If-then-else statement allows you to compare values and execute different parts of a script based on that comparison.

    Basic format

    if (v1 operator v2) { commands }
    ...
    ...
    ...
    $v1 & $v2

    Returns the first and second parameters of an if-then-else comparison. So, in the case of this comparison:

    if (text isin sometext) { ... }

    $v1 will return "text" and $v2 will return "sometext".


So...
Code:
      if ($did(8).seltext isnum) { %a -r $v1 }[color:gray] | ; &lt;- $v1 = $did(8).seltext[/color]
      if ($did(6).seltext isalnum) { %a %a -g $v1 }[color:gray] | ; &lt;- $v1 = $did(6).seltext[/color]
      if ($did(4).seltext isalnum) { %a %a -s $v1 }[color:gray] | ; &lt;- $v1 = $did(4).seltext[/color]
Posted By: s0tt0 Re: Help with script (if elseif and variables) - 05/03/05 01:01 PM
doh yes smile now i understand and it should work, but it doesnt frown just nothing happens. and how does variable "a" gets its value?

EDIT: got it to work but it still doesnt show values like "-s" in the infoline . its says -S Unknown command and i cant understand what purpose variable "a" has in there. it should display the -r and value in the infoline, but why theres 2 of them like in here:
if ($did(6, seltext) isalnum) { %a %a -g $v1 }
Posted By: Iori Re: Help with script (if elseif and variables) - 05/03/05 01:16 PM
Weird, "=" chars somehow got lost.
Anyway...
Code:
  if ($did(12).state == 1) {
    if ($did(2).seltext isalnum) {
      var %a
      if ($did(8).seltext isnum) { %a [color:blue]=[/color] -r $v1 }
      if ($did(6).seltext isalnum) { %a [color:blue]=[/color] %a -g $v1 }
      if ($did(4).seltext isalnum) { %a [color:blue]=[/color] %a -s $v1 }
      msg #mychannel !info %a $did(2).seltext
    }
  }
  else {
    if ($did(2).seltext isalnum) { msg #mychannel !info $v1 }
  }
Posted By: s0tt0 Re: Help with script (if elseif and variables) - 05/03/05 01:29 PM
omg thank you so much it works now perfectly smile
you've been so helpful, really appriciate it smile

CASE CLOSED
© mIRC Discussion Forums