Re: :assign and scopes

Bram Moolenaar <[email protected]> Tue, 06 Jan 2004 11:05:59 +0100
Newsgroups gmane.comp.tools.aap.devel
Message-ID <[email protected]>
Richard Boulton wrote:

> Quick question - should ":assign _top.foo" work in a subrecipe?
> 
> I have:
> 
> ====main.aap====
> :child tmp.aap
> :print $foo
> ========
> 
> ====tmp.aap====
> :print "foo" | :assign _top.foo
> ========
> 
> 
> aap returns:
> Aap: Error in recipe "/data/home/richard/stuff/aap_example/main.aap" 
> line 2: Unknown variable: "foo"
> 
> 
> If tmp.aap contains
> 
> :print "foo" | :assign tmp
> _top.foo = $tmp
> 
> 
> aap returns "foo" as expected.

This appears to be a bug in ":assign".  It simply doesn't take care of
the scope.  Change the _pipe_assign() function in Commands.py to:

def _pipe_assign(line_nr, recdict, raw_arg, pipein):
    """Handle: ":assign var".  Can only be used in a pipe."""
    rpstack = getrpstack(recdict, line_nr)
    assert_var_name(rpstack, raw_arg)

    # Separate scope and decide which dictionary to use.
    rd, scope, varname = get_scope_recdict(rpstack, recdict, raw_arg, 1)
    rd[varname] = pipein


-- 
hundred-and-one symptoms of being an internet addict:
139. You down your lunch in five minutes, at your desk, so you can
     spend the rest of the hour surfing the Net.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///          Creator of Vim - Vi IMproved -- http://www.Vim.org          \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\  Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html  ///


-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click