mIRC Homepage
Posted By: XTZGZoReX Commands on multiple lines. - 19/01/08 12:52 PM
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.
Posted By: genius_at_work Re: Commands on multiple lines. - 19/01/08 05:35 PM
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
Posted By: XTZGZoReX Re: Commands on multiple lines. - 19/01/08 09:08 PM
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!
}
Posted By: RoCk Re: Commands on multiple lines. - 19/01/08 09:30 PM

A while loop?

/help /while
Posted By: XTZGZoReX Re: Commands on multiple lines. - 20/01/08 10:52 AM
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.
Posted By: Riamus2 Re: Commands on multiple lines. - 20/01/08 11:17 AM
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).
Posted By: XTZGZoReX Re: Commands on multiple lines. - 20/01/08 01:34 PM
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?
Posted By: genius_at_work Re: Commands on multiple lines. - 20/01/08 05:12 PM
/if, /elseif, /else, /while, etc are not commands. They are control structures. That is why commands do not accept { } brackets.

-genius_at_work
Posted By: XTZGZoReX Re: Commands on multiple lines. - 21/01/08 12:15 PM
So it is not possible in any way?

Well, then: Is it possible to check what the last executed command was?
Posted By: genius_at_work Re: Commands on multiple lines. - 21/01/08 02:51 PM
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
Posted By: foshizzle Re: Commands on multiple lines. - 21/01/08 04:59 PM
if he hasnt figured it out, i think he wants a for event :: or something that acts like it
Posted By: XTZGZoReX Re: Commands on multiple lines. - 22/01/08 06:01 PM
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.
Posted By: Riamus2 Re: Commands on multiple lines. - 22/01/08 09:04 PM
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.
Posted By: XTZGZoReX Re: Commands on multiple lines. - 23/01/08 06:13 PM
Haha. Good idea. Never really though of that. Thanks! I suppose that'll be it for now.
Posted By: XTZGZoReX Re: Commands on multiple lines. - 28/01/08 02:27 PM
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.
© mIRC Discussion Forums