Sylvain Viart | 2 Dec 2002 03:21
Picon

Re: Includes

Hi,

Steve Hall wrote:
> 
> Is there any way to include a script within another script so that the
> s: scope of the first is available to the second? I want to create
> a library of variables external to the functions that use them, but
> still not make them global.
>
In this message 
http://groups.yahoo.com/group/vim/message/34855

I've copied a piece of vim code to get  the <SID> of a script.

Here how it could be used:

let sid=GetSID('part/of/the/path/to/the/sourced/script')

With the SID you can get any information in the sourced script
above.

May be just about function in fact...

But you could do  (not tested)

" in the sourced script
func! <SID>GetVar(varname)
 exe "let v=s:".a:varname
 return v
endf

and then when you want a variable:

let sid=GetSID('golbal/var.vim')
" call the script function with the specified argument
exe "let v=\<SNR>".sid."_Getvar(".varname.")"

It may be more tricky, but if that's what you want, you have a hint. ;)

Some references 
:he scriptnames
:he <SID>
:he execute

HTH,
--

-- 
- Sylvain Viart -
  - Blainville - Canada -
Je parle aussi le français.


Gmane