mIRC Home    About    Download    Register    News    Help

Print Thread
#193401 19/01/08 12:52 PM
Joined: Sep 2007
Posts: 65
X
Babel fish
OP Offline
Babel fish
X
Joined: Sep 2007
Posts: 65
Would it be possible to make a command that works like this?:

Code:
on *:input:test: {
  /somecmd
    /some special cmds here
    /more special cmds here
  /endsomecmd
}


Or maybe use {}-brackets like in If-statements?

What I mean, is that if I then entered echo as one of the "special cmds" in the middle, it wouldnt be parsed as the normal echo alias, but rather something else.

Thanks.


GamerzWoW
The Official GamerzPlanet WoW Server
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
You can make aliases. Example:

Code:

alias sample {
  echo 2 -a This is line 1
  echo 3 -a This is line 2
  echo 4 -a This is line 3
}

on *:INPUT:test:{
  sample
}



-genius_at_work

Joined: Sep 2007
Posts: 65
X
Babel fish
OP Offline
Babel fish
X
Joined: Sep 2007
Posts: 65
Mm, more like this Python implementation I found:

Code:
alias testpython {
echo -s Testing Python!
goto $startpy($script, $scriptline)
print 'Testing Python #2'
for x in reversed(xrange(3)):
    print x
def testfunc():
    print 'Testing Python #3'
testfunc()
:0
echo -s An exception occurred somewhere!!
return
:1
echo -s Test successful!
}

Last edited by XTZGZoReX; 19/01/08 09:09 PM.

GamerzWoW
The Official GamerzPlanet WoW Server
Joined: Dec 2002
Posts: 2,031
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,031

A while loop?

/help /while

Joined: Sep 2007
Posts: 65
X
Babel fish
OP Offline
Babel fish
X
Joined: Sep 2007
Posts: 65
Erm, let's take it another way...

Code:
on *:input:*: {
  if ( $1 == lala ) {
    do something
  }
}


We all know the /if command. Basically, what I want to do is make a command where I can use the {} brackets like in /if.


GamerzWoW
The Official GamerzPlanet WoW Server
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
The best method is to use an alias as was suggested. Of course, that's without knowing what you're trying to do. But you wouldn't just be able to throw {}'s for multiple lines anywhere you want... they'd only be valid with commands that accept them (if, elseif, else, etc).


Invision Support
#Invision on irc.irchighway.net
Joined: Sep 2007
Posts: 65
X
Babel fish
OP Offline
Babel fish
X
Joined: Sep 2007
Posts: 65
That's what I mean. /if, /else, /elseif are all commands. So I thought that it might be possible to make aliases that accept {}-brackets too?


GamerzWoW
The Official GamerzPlanet WoW Server
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
/if, /elseif, /else, /while, etc are not commands. They are control structures. That is why commands do not accept { } brackets.

-genius_at_work

Joined: Sep 2007
Posts: 65
X
Babel fish
OP Offline
Babel fish
X
Joined: Sep 2007
Posts: 65
So it is not possible in any way?

Well, then: Is it possible to check what the last executed command was?


GamerzWoW
The Official GamerzPlanet WoW Server
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
It is only possible in the way described, by using an /alias. It is not possible in the way you are looking for.

The last executed command is the one immediately before the currently executing command. It is your script, so you should know in what order the commands are executed.

-genius_at_work

Joined: Aug 2007
Posts: 334
Pan-dimensional mouse
Offline
Pan-dimensional mouse
Joined: Aug 2007
Posts: 334
if he hasnt figured it out, i think he wants a for event :: or something that acts like it


This is not the signature you are looking for
Joined: Sep 2007
Posts: 65
X
Babel fish
OP Offline
Babel fish
X
Joined: Sep 2007
Posts: 65
No - it's not like I don't know what the last command was, but I'm trying to make an alias that depends on the lastly executed command.


GamerzWoW
The Official GamerzPlanet WoW Server
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Have the alias called with some identifing word/character/number so you know where it's called from... For example, if the alias is called "Stats", you can call it as /stats ontext or /stats onnotice or /stats oninput or something like that. If that's not an option, have the events that the alias cares about set a variable with the same kind of identifying item that the alias will check when called.


Invision Support
#Invision on irc.irchighway.net
Joined: Sep 2007
Posts: 65
X
Babel fish
OP Offline
Babel fish
X
Joined: Sep 2007
Posts: 65
Haha. Good idea. Never really though of that. Thanks! I suppose that'll be it for now.


GamerzWoW
The Official GamerzPlanet WoW Server
Joined: Sep 2007
Posts: 65
X
Babel fish
OP Offline
Babel fish
X
Joined: Sep 2007
Posts: 65
Oh and, I would like to update you guys here.

Code:
on *:input:*: {
  if ( $1 == .php ) {
    <?php {
      echo -a Uses brackets!
    } ?>
    echo -a Really!
  }
}

alias <?php {
  set %php true
}

alias ?> {
  unset %php
}


So apparently, you can use brackets in your own aliases, in case any of you wondered/didn't know.


GamerzWoW
The Official GamerzPlanet WoW Server

Link Copied to Clipboard