mIRC Home    About    Download    Register    News    Help

Print Thread
Commands on multiple lines. #193401 19/01/08 12:52 PM
Joined: Sep 2007
Posts: 65
X
XTZGZoReX Offline OP
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
Re: Commands on multiple lines. [Re: XTZGZoReX] #193418 19/01/08 05:35 PM
Joined: Oct 2005
Posts: 1,741
G
genius_at_work Offline
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

Re: Commands on multiple lines. [Re: genius_at_work] #193478 19/01/08 09:08 PM
Joined: Sep 2007
Posts: 65
X
XTZGZoReX Offline OP
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
Re: Commands on multiple lines. [Re: XTZGZoReX] #193484 19/01/08 09:30 PM
Joined: Dec 2002
Posts: 2,021
R
RoCk Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,021

A while loop?

/help /while

Re: Commands on multiple lines. [Re: RoCk] #193508 20/01/08 10:52 AM
Joined: Sep 2007
Posts: 65
X
XTZGZoReX Offline OP
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
Re: Commands on multiple lines. [Re: XTZGZoReX] #193510 20/01/08 11:17 AM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
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
Re: Commands on multiple lines. [Re: Riamus2] #193515 20/01/08 01:34 PM
Joined: Sep 2007
Posts: 65
X
XTZGZoReX Offline OP
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
Re: Commands on multiple lines. [Re: XTZGZoReX] #193525 20/01/08 05:12 PM
Joined: Oct 2005
Posts: 1,741
G
genius_at_work Offline
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

Re: Commands on multiple lines. [Re: genius_at_work] #193557 21/01/08 12:15 PM
Joined: Sep 2007
Posts: 65
X
XTZGZoReX Offline OP
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
Re: Commands on multiple lines. [Re: XTZGZoReX] #193563 21/01/08 02:51 PM
Joined: Oct 2005
Posts: 1,741
G
genius_at_work Offline
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

Re: Commands on multiple lines. [Re: genius_at_work] #193568 21/01/08 04:59 PM
Joined: Aug 2007
Posts: 333
foshizzle Offline
Fjord artisan
Offline
Fjord artisan
Joined: Aug 2007
Posts: 333
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
Re: Commands on multiple lines. [Re: foshizzle] #193614 22/01/08 06:01 PM
Joined: Sep 2007
Posts: 65
X
XTZGZoReX Offline OP
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
Re: Commands on multiple lines. [Re: XTZGZoReX] #193630 22/01/08 09:04 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
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
Re: Commands on multiple lines. [Re: Riamus2] #193667 23/01/08 06:13 PM
Joined: Sep 2007
Posts: 65
X
XTZGZoReX Offline OP
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
Re: Commands on multiple lines. [Re: XTZGZoReX] #194023 28/01/08 02:27 PM
Joined: Sep 2007
Posts: 65
X
XTZGZoReX Offline OP
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