Loading ...
Sorry, an error occurred while loading the content.
 

Re: Includes

Expand Messages
  • Sylvain Viart
    Hi, ... In this message http://groups.yahoo.com/group/vim/message/34855 I ve copied a piece of vim code to get the of a script. Here how it could be
    Message 1 of 4 , Dec 1, 2002
      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.
    • Steve Hall
      ... ;) Heh, tricky indeed--in two months I ll never remember how it works! Suppose I could just make them globals. (But thanks for the example, I ve
      Message 2 of 4 , Dec 1, 2002
        On Sun, 2002-12-01 at 21:21, Sylvain Viart wrote:
        >
        > 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?
        > >
        >
        > [clever local s:var announcing function example]
        >
        > It may be more tricky, but if that's what you want, you have a hint.
        ;)

        Heh, tricky indeed--in two months I'll never remember how it works!
        Suppose I could just make them <shudder> globals. (But thanks for the
        example, I've stashed it in the library for later reference.)

        Steve Hall [ digitect@... ]
      Your message has been successfully submitted and would be delivered to recipients shortly.