mIRC Home    About    Download    Register    News    Help

Print Thread
#230416 07/03/11 10:29 PM
Joined: Dec 2008
Posts: 1,515
westor Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
Hello,

How can i do this happens?

[code]
alias test {
$iif(%TEST,echo -s EXIST THE TEST | return %TEST,echo there is not EXIST)
}


Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-
westor #230417 07/03/11 10:36 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Use an alias in the $iif(). Or put the echoes in the script that calls your alias instead of in the alias.

Code:
if $test(whatever) { echo -a exists }
else { echo -a doesn't exist }

Last edited by Riamus2; 07/03/11 10:38 PM.

Invision Support
#Invision on irc.irchighway.net
westor #230418 07/03/11 10:40 PM
Joined: Jul 2006
Posts: 4,149
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,149
Use correct syntax/commands, you know, /if.
Code:
if (%test) {
 echo -a % $+ test is different from 0, $false and $null
 echo curly bracket let you make bloc of commands
 unset %test
}
else {
echo -a % $+ test is either 0, $null, or $false
}


Last edited by Wims; 07/03/11 10:41 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
westor #230419 07/03/11 10:42 PM
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
You have to construct the code as follows:
Code:
alias test {
  echo -s $iif(%test,The test exists : $v1,The $+(%,test) variable doesn't exist)
}
Code:
alias test {
  if (%TEST) {
    echo -s THE $+(%,test) exists 
    echo -s %TEST
  }
  else {
    echo -s the $+(%,test) doesn't EXIST
  }
}

Riamus2 #230420 07/03/11 10:42 PM
Joined: Dec 2008
Posts: 1,515
westor Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
Ok and if i have something like this? how can i change it to work?

Code:
alias fkc_check_aliases {
  unset %FKC_TEMP
  var %a = f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,sf1,sf2,sf3,sf4,sf5,sf6,sf7,sf8,sf9,sf10,sf11,sf12,cf1,cf2,cf3,cf4,cf5,cf6,cf7,cf8,cf9,cf10,cf11,cf12,fkc_crdate,fkc_ver,fkc_owner,fkeys_restore,fkeys-changer,fkeys-changer-settings,fkc_settings,fkc_error,fkc_error_load,fkc_menu,fkc_color,fkc_font,addon,d_min,d_max,d_close,s_close,red,green,fkeys,fkeys_settings,fkc_mdx,fkc_animate,fkc_sclick,fkeys_check_fkeys_on,fkc_about,fkc_download,fkc_download_fail,fkc_remove,fkc_count,fkc_check,fkc_settings_check,fkc_restore,fkeys_load_themes,fkeys_load_fonts,fkc_download_install,fkc_update_fail,fkc_help_unload,fkc_report_bug,fkc_report_suggest,malaka1,malaka2
  var %x = 1
  while (%x <= $numtok(%a,44)) {
    if (!$isalias($gettok(%a,%x,44))) { set -e %FKC_TEMP $addtok(%FKC_TEMP,$gettok(%a,%x,44),32) }
    if ((%x == $numtok(%a,44) && (!%FKC_TEMP))) { $iif($isid == $true,return 0,echo -ac info * /fkc_check_aliases: does not missing any alias from the addon - RETURN: $chr(40) $+  $+ 0 $+  $+ $chr(41) $+ ) }
    elseif ((%x == $numtok(%a,44) && (%FKC_TEMP))) { $iif($isid == $true,return %FKC_TEMP,echo -ac info * /fkc_check_aliases: missing $iif($numtok(%FKC_TEMP,32) !== 1,$v1 aliases,$iif($numtok(%FKC_TEMP,32) == 1,an alias)) from the addon - RETURN: $chr(40) $+  $+ %FKC_TEMP $+  $+ $chr(41) $+ ) | set %FKC_ERROR MISSING $iif($numtok(%FKC_TEMP,32) == 2,ALIASES,$iif($numtok(%FKC_TEMP,32) == 1,ALIAS)) " $+ %FKC_TEMP $+ " | unset %FKC_TEMP }
    inc %x
  }
  inc %x
}


and i wanna do it like this

Code:
alias fkc_check_aliases {
  unset %FKC_TEMP
  var %a = f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,sf1,sf2,sf3,sf4,sf5,sf6,sf7,sf8,sf9,sf10,sf11,sf12,cf1,cf2,cf3,cf4,cf5,cf6,cf7,cf8,cf9,cf10,cf11,cf12,fkc_crdate,fkc_ver,fkc_owner,fkeys_restore,fkeys-changer,fkeys-changer-settings,fkc_settings,fkc_error,fkc_error_load,fkc_menu,fkc_color,fkc_font,addon,d_min,d_max,d_close,s_close,red,green,fkeys,fkeys_settings,fkc_mdx,fkc_animate,fkc_sclick,fkeys_check_fkeys_on,fkc_about,fkc_download,fkc_download_fail,fkc_remove,fkc_count,fkc_check,fkc_settings_check,fkc_restore,fkeys_load_themes,fkeys_load_fonts,fkc_download_install,fkc_update_fail,fkc_help_unload,fkc_report_bug,fkc_report_suggest,malaka1,malaka2
  var %x = 1
  while (%x <= $numtok(%a,44)) {
    if (!$isalias($gettok(%a,%x,44))) { set -e %FKC_TEMP $addtok(%FKC_TEMP,$gettok(%a,%x,44),32) }
    if ((%x == $numtok(%a,44) && (!%FKC_TEMP))) { $iif($isid == $true,return 0,echo -ac info * /fkc_check_aliases: does not missing any alias from the addon - RETURN: $chr(40) $+  $+ 0 $+  $+ $chr(41) $+ ) }
    elseif ((%x == $numtok(%a,44) && (%FKC_TEMP))) { $iif($isid == $true,return %FKC_TEMP | set %FKC_ERROR MISSING $iif($numtok(%FKC_TEMP,32) == 2,ALIASES,$iif($numtok(%FKC_TEMP,32) == 1,ALIAS)) " $+ %FKC_TEMP $+ " | unset %FKC_TEMP,echo -ac info * /fkc_check_aliases: missing $iif($numtok(%FKC_TEMP,32) !== 1,$v1 aliases,$iif($numtok(%FKC_TEMP,32) == 1,an alias)) from the addon - RETURN: $chr(40) $+  $+ %FKC_TEMP $+  $+ $chr(41) $+ ) | set %FKC_ERROR MISSING $iif($numtok(%FKC_TEMP,32) == 2,ALIASES,$iif($numtok(%FKC_TEMP,32) == 1,ALIAS)) " $+ %FKC_TEMP $+ " | unset %FKC_TEMP }
    inc %x
  }
  inc %x
}


Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-
Riamus2 #230421 07/03/11 10:43 PM
Joined: Dec 2008
Posts: 1,515
westor Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
- DELETED - (sorry for second post)

Last edited by westor; 07/03/11 10:44 PM.

Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-
westor #230422 07/03/11 10:50 PM
Joined: Jul 2006
Posts: 4,149
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,149
Showing your code isn't needed, you quite clearly showed what you wanted to do with your $iif() example, the solution is to use the proper syntax, /if.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Wims #230423 07/03/11 10:53 PM
Joined: Dec 2008
Posts: 1,515
westor Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
Yes but how ? i don't know how. i tryied with an extra alias but does not return anything.


Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-
westor #230424 07/03/11 11:07 PM
Joined: Jul 2006
Posts: 4,149
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,149
$iif isn't mean to execute command but to return something, which is why you can't do multiple "command" with it, it doesn't make sense to talk about command when using $iif, use /if.

Side note, an extra alias is a workaround, not the solution, the help file never stated to use $iif with an alias when you want to do more than one command.

Quote:
Yes but how ? i don't know how. i tryied with an extra alias but does not return anything.
Yes you do, you just learned that you need to use if, not $iif

Code:
alias wrong {
$iif(condition, command | command)
}
alias right {
if (condition) {
command
command
}
}


Last edited by Wims; 07/03/11 11:19 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Wims #230425 07/03/11 11:25 PM
Joined: Dec 2008
Posts: 1,515
westor Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
Problem solved i have added an alias.


Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-
westor #230426 08/03/11 12:29 AM
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
$iif() is handy when you make a comparison for a simple true or false, not to be interwoven with the if-then-else condition. Most of the time /if is more efficient than using $iif(). I used to abuse $iif() quit literally, and I've learned it the hard way. You'll learn from your own experience eventually.


Link Copied to Clipboard