Hi,

Hari Krishna Dara wrote:
>
> I am trying to use the new vim7 "object-based" features and am stuck
> with an issue in using autoload style variables. Save the below as t.vim
> in your autoload directory and execute it (:runtime autoload/t.vim).
> 
> let t#var = 'something'
> 
> let s:hash = {}
> function! s:hash.func()
>   echomsg 'from numbered function scope: '. t#var
> endfunction
> 
> echomsg 'from global scope: '. t#var
> call s:hash.func()
> <<<<
> 
> you get the below output:
> 
> from global scope: something
> Error detected while processing function 3:
> line    1:
> E121: Undefined variable: t#var
> E15: Invalid expression: 'from numbered function scope: '. t#var
> 
> Is there something wrong that I am doing or is this a bug?

inside a function you have to reference global variables with the "g:"
prefix even if it's an autoload variable, i.e.

  function! s:hash.func()
    echomsg 'from numbered function scope: '. g:t#var
  endfunction

Regards,
Jürgen

-- 
Jürgen Krämer                              Softwareentwicklung
HABEL GmbH & Co. KG                        mailto:[EMAIL PROTECTED]
Hinteres Öschle 2                          Tel: +49 / 74 61 / 93 53 - 15
78604 Rietheim-Weilheim                    Fax: +49 / 74 61 / 93 53 - 99

Reply via email to