Marc Weber wrote:
Do I have missed a non quoting version of <f-args> ?
Consider this example:
function! T(...)
for a in a:000
echom 'arg:'.string(a)
endfor
endfunction
------ 8< ------ 8< start test.vim < ------ 8< ------ 8< ------ 8<
command! -nargs=* -buffer TestAddSeven :call T(7,<f-args>)
command! -nargs=* -buffer Test2 :exec "call
T(7,".join([<f-args>],',').')'
TestAddSeven 4 'abc'
echo "Test 2"
Test2 3 'abc'
------ >8 ------ >8 end >8 ------ >8 ------ >8 ------ >8 ------ >8
------ >8 ------ >8 output ------ >8 ------ >8 ------ >8 ------ >8
arg:7
arg:'4' << here you can see that all arguments get extra extra
quotes
arg:'''abc'''
Test 2
arg:7
arg:3
arg:'abc'
------ 8< ------ 8< ------ 8< ------ 8< ------ 8< ------ 8< ------ 8<
So is there a non quoting version of <f-args> which behaves like the
join([<f-args>],', ') part?
Marc
Here are the various ways in which a user-command may pass arguments:
:command arg1 arg2 arg3 arg4 arg5
<args> passes
arg1 arg2 arg3 arg4 arg5
<q-args> passes
"arg1 arg2 arg3 arg4 arg5"
<f-args> passes
"arg1","arg2","arg3","arg4","arg5"
The fact that the arguments are quoted is usually no problem: if you try to
use a String where a Number is expected, Vim will use the longest numeric part
at the start of the string, or 0 if there is nothing at the start that looks
like a Number. Using a Number where a String is expected will simply use the
decimal representation of the Number. If you still have problems with quoting,
you may construct a wrapper function to convert the arguments: if a quoted
argument has in fact a numeric value, then
let num1 = a:param1 + 0
will extract that value as a Numeric variable. You can check that the argument
is numeric by doing the conversion back and forth:
if a:param1 == (a:param1 + 0) . ""
" the value is numeric (and decimal)
else
" the value is not strictly numeric
endif
The above is not perfect, however: for instance, "0xfc" + 0 gives 252; then
252 . "" gives "252" which is not equal to "0xfc".
Best regards,
Tony.
--
According to the obituary notices, a mean and unimportant person never
dies.