Reman
Reman

Reputation: 8109

What is wrong with this (vimscript) code?

Does anyone know why this never doesn't work:

if !exists("g:removenumbchar")
  if a:type == "remove"
   let g:removenumbchar = "How many characters do you want remove at the end?"
  elseif a:type == "add"
   let g:removenumbchar = "How many characters do you want add at the end?"
  endif
endif  
let c = inputdialog(g:removenumbchar)

even if "a:type" value is correct, sometimes it shows the first sentence sometimes the second one. I've never understood how this comes.

Upvotes: 0

Views: 122

Answers (1)

Gareth McCaughan
Gareth McCaughan

Reputation: 19971

Well, g:removenumbchar will persist across calls to the function I assume this is in, so after you've called it once you'll get the same message every time regardless of what's in a:type on subsequent calls. Could that be what you're seeing?

Upvotes: 2

Related Questions