# eval

Change the behaviour of a set of commands

Syntax

    eval [-q] [-r=<window>] <command>

Description

This command is useful to execute variable command sequences.
<command> is first evaluated as a normal parameter (thus identifiers and variables are substituted) then the evaluated string is executed as a command sequence.
-q causes eval to silently ignore the errors inside <command> and continue execution.
This command may be used to rebind the <command> to a specified window. <command> shares the local variables with this command scope so you can easily exchange data with it. Remember that <command> is still a normal parameter and it must be enclosed in quotes if youwant it to be a complex command sequence. eval propagates the <command> return value.

Examples

        # evaluate a variable command
        if(%somecondition)%tmp = "echo yeah"
        else %tmp = "echo -i=10 yeah"
        eval %tmp
        # Rebind the command to the #linux channel to get the user list
        eval -r=$channel(#linux) "%Nicks[]=$chan.array;"
        # A nice alias that allows iterating commands through all the consoles
        # This is by LatinSuD :)
        alias(iterate)
        {
            %ctxt[]=$window.list(console,all)
            for(%i=0;%i<%ctxt[]#;%i++)
            {
                eval -r=%ctxt[%i] $0-
            }
        }
        iterate echo Hi ppl! :)
        # A little bit shorter (but less "colorful") version might be...
        alias(iterate)
        {
            foreach(%x,$window.list(console,all))
                    eval -r=%x $0-;
        }
        iterate echo Hi again!
        # Evaluate a command block
        eval "{ echo First command!; echo Second command!; }"

Main, Commands

KVIrc 3.0.0 Documentation
Generated by root at Sat Oct 16 22:01:45 2004