mIRC Home    About    Download    Register    News    Help

Print Thread
#120015 12/05/05 04:27 PM
Joined: May 2005
Posts: 6
D
duklaa Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: May 2005
Posts: 6
I have some aliases defined that I would like to use in remote scripts but I think I am not clear on the syntax.

e.g. My aliases.ini defines
/ca /say California

and then I want to use this in a remote:

on 1:TEXT:where are you from:?:/msg $nick /ca

However this seems to send the string "/ca" instead of executing the alias.

What am I doing wrong?

#120016 12/05/05 04:32 PM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Try /ca return California.

Code:
on 1:TEXT:where are you from:?: {
  msg $nick $ca
}

#120017 12/05/05 04:52 PM
Joined: May 2005
Posts: 6
D
duklaa Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: May 2005
Posts: 6
Thanks. That worked.

However, now I cannot manually type /ca to say "California".

Does this mean that aliases that one uses manually and aliases that one uses in scripts are different? If that's the case, then I think that's where my conceptual confusion arose from.

#120018 12/05/05 05:08 PM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
No they're entirely the same it's how you wish to use them, that's all.

Just don't use the /SAY command because you're not specifying a target, use the /MSG command.

If you use the /RETURN command as I did earlier you can use a custom identifier for your data.

Code:
alias test { 
  return Testing..
}


//echo -a $test will echo Testing...

You can still use the /ca command/alias in your script if you want to using the $ sign and your alias shows your using the return command to return data with another command (or something along those lines..).

/alias /ca /msg $nick California.

Then have /ca in your On Text event.

One minor note, you don't have to call aliases from the Aliase section of the Remote Editor, you can define your aliases in Remote Scripts where you put the On Text events.

Example:

Code:
alias ca {
  msg $nick California
}


-Andy

#120019 12/05/05 05:28 PM
Joined: May 2005
Posts: 6
D
duklaa Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: May 2005
Posts: 6
Thanks. I think I understand it better now. But I am still confused about one point:

What I want to do is use an alias two ways:
- to type in the current window, and
- in a remote script.

e.g.,
I want to be able to able to manually type
/ca in a window and have it exand to california, AND
I want to use in a remote script to automatically reply to a question.

If I change the /say to /msg $nick form then it works fine in the remote script but mirc complains "insufficient parameters" when I type /ca in a query window.

Thanks. I appreciate the help in clearing my conceptual confusion.

#120020 12/05/05 05:43 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
you can do something along the lines of:

In alias:

/ca $iif($1,msg $1 California,say California)

Then, in remotes:

on 1:TEXT:where are you from:?: { ca $nick }

Last edited by Riamus2; 12/05/05 05:51 PM.

Invision Support
#Invision on irc.irchighway.net
#120021 12/05/05 05:45 PM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Try this.

Code:
alias ca {
  if (%target) { 
    msg $target California 
    unset %target
  }
  else { say California }
}

On *:Text:where do you come from*:?: { 
  set %target $true
  ca
}


When you type /ca manually in any window it uses the SAY command. When it's called from a script it uses the MSG command.

An explanation of how we managed this:

When someone messages us with where are you from? We set a variable with a $true value and triggers our /CA alias. In our /CA alias it checks to see if the variable exists and if it does we use the /MSG command then unsets the variable, so it will never always be /MSG.

When we type /CA manually obviously the variable would be set so after we check to see if the variable exists using an IF statement, we use the else statement to use the say command.

Hope this helps and sheds some light.

Edit: Riamus' way is better to use, more simplistic. laugh
-Andy

#120022 12/05/05 05:51 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
I'm enjoying using $iif's... I've never really used them until recently. smile

duklaa: as an explanation of $iif..

$iif is an if/then/else statement. If the first part is true, do the first command, if it's false, do the second statement):


Example ways to look at the identifier
$iif(if,then,else)
$iif(question,true command,false command)

Note that it would also allow you to use /ca nick and it will allow you to send it to anyone without being in a query window with them. It would also work with /ca #chan as well.

Edit for above: I did change msg $active to say. Forgot about the say command. smile


Invision Support
#Invision on irc.irchighway.net
#120023 12/05/05 06:49 PM
Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
on 1:TEXT:where are you from:?:/msg $nick $ca
alias ca {
if ($isid) return California
if ($1) msg $1 California
else say California
}


$iif() does the same as an if, but an if does the same too and faster also...

#120024 12/05/05 07:04 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
How is it faster?

Yes, $iif is an if/then/else command as I said. It's just a condensed version of that. For that reason, it should run faster and be cleaner code. If it's not faster, I'm curious as to why.


Invision Support
#Invision on irc.irchighway.net
#120025 12/05/05 11:41 PM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
I would say its the parsing of the line thats taking it longer maybe. But $iif is slower for sure.

example
Code:
/speedtest {
  var %1 = 1
  var %2 = 2
  var %l = 10000
  var %t = $ticks | var %i = %l | while (%i) { !.echo -q blah                                             | dec %i } | echo -st looptime $calc($ticks - %t) | var %r = $calc($ticks - %t)
  var %t = $ticks | var %i = %l | while (%i) { !.echo -q $iif(%1 == %2,blah,blob)                         | dec %i } | echo -st $!iif == $calc($ticks - %t - %r)
  var %t = $ticks | var %i = %l | while (%i) { !.echo -q $iif(%1 != %2,blah,blob)                         | dec %i } | echo -st $!iif != $calc($ticks - %t - %r)
  var %t = $ticks | var %i = %l | while (%i) { !.echo -q blah                                             | dec %i } | echo -st looptime $calc($ticks - %t) | var %r = $calc($ticks - %t)
  var %t = $ticks | var %i = %l | while (%i) { if (%1 == %2) { !.echo -q blah } | else { !.echo -q blob } | dec %i } | echo -st IF (==). $calc($ticks - %t - %r)
  var %t = $ticks | var %i = %l | while (%i) { if (%1 != %2) { !.echo -q blob } | else { !.echo -q blob } | dec %i } | echo -st IF (!=). $calc($ticks - %t - %r)
}


Adjust %l up for more loops if pc speed is still to great to see a difference.

Personally tho on what you used it on I would not have a problem, not like its being called 10000 a second eh?

#120026 13/05/05 02:32 AM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Interesting. smile

Well, I guess it comes down to how complex the script is and if you want it to be condensed down or not.


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard