I've a new patch for the macro language (yet another). You can find it here:
http://ajbj.free.fr/nedit/nedit5.5dev/patches/MultipleAssignment.diff

I didn't patch the help file yet, but here's the jist (taken from the patch
file):

Assign multiple lvalues in one statement

    This patch allows you to assign a set of variables in a lvalue list from
the content of an array. This has the appearance of a tuple. The keys used to
retrieve the values from the array expression on the right are numeric values
starting with 1. If a key is missing, your macro will fail.

    Given the following (implemented as new built-in functions in this patch):
            define args {
                return $args
            }
            define n_args {
                i = 0;
                while (i in $1)
                    ++i
                return i
            }
    You can assign a list of symbols to the content of such an array using a
list assign, thus:

            (x, y, z) = args(a, b, c)

    This is equivalent to

            x = a
            y = b
            z = c

    This technique can be useful for retrieving argument values in your
functions:

            (str, regex, count) = $args

or for returning "tuples" from them:

            define myfunc {
                ...
                return args(isOk, message)
            }
            ...
            (success, msg) = myfunc()

If you need to count the number of variables that can be assigned in this way,
use the n_args() function:

            ...
            result = myfunc()       # we expect result is an array
            if (n_args(result) >= 2)
                (success, msg) = result
====
I forgot to mention you can also assign to array members, eg

    (a, b, c["hello","there"]) = ("forA", "forB", "forC")

Tony
-- 
NEdit Develop mailing list - [email protected]
http://www.nedit.org/mailman/listinfo/develop

Reply via email to