On Wed, 17 May 2006 at 10:58pm, A.J.Mechelynck wrote: > Steve Hall wrote: > > Is there a way to construct the code below to avoid the "E193 > > :endfunction not inside a function" error in Vim 6.4 when loading a > > Vim 7.0 script? > > > > This for-endfor construct produces the error: > > > > function! MyFunct() > > if v:version < 700 > > return > > endif > > ... > > for i in range(tabpagenr('$')) > > ... > > endfor > > endfunction > > > > The runtime condition is fine, earlier versions avoid the problem. > > > > I know I can avoid it by silencing :source call but I'd rather not do > > that if there's some other trick. > > > > Thanks. > > > > > > > It might be a bug in v6, but are those still being fixed? Anyway, until > Bram comes back from holiday, I guess one possibility would be to > replace the for/endfor by a "v6-compatible" construct like > > let i = 0 > while i < tabpagenr('$') > ... > let i = i+1 > endwhile > > Or does that choke on the "unknown" tabpagenr() function? > > > Best regards, > Tony.
Yes, this might be a bug, as I observed that you can put any gibberish in a function and still have it sourced (I put vbscript in a couple of plugins). As a trick, how about enclosing :endfor inside an exec? exec "endfor" This seems to take the error message away, though I don't know if it actually works (don't see any reason why it shouldn't). -- Thanks, Hari __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com