Saturday, October 22, 2016

Re: E117: Unknown function, dict member called as timer's handler

Ni Va wrote:

> Applying timer_start help, I would like to differ from example by calling a function declared as dict member and passing FuncName at timer_start parameter.
>
> I got that message :
>
> E117: Unknown function:
>
> -------------------THE CODE---------
>
> fu! g:messagesManager.DisplayMessage(timer) "{{{
> echo printf("%s",self.messagesBuffer[self.currentMessageIndex])
> let self.currentMessageIndex+=1
> if self.currentMessageIndex==len(self.messagesBuffer)
> let self.currentMessageIndex=0
> endif
> endfu
> "}}}
> fu! g:messagesManager.StartDisplay() "{{{
> " if has('timers') && !exists('s:timer')
> let FuncRef = function('self.DisplayMessage')
> let FuncName = string(FuncRef)
> if has('timers')
> let s:timer = timer_start(1000,
> \ FuncName, {'repeat': 10})
> else
> echo "timers not supported by your version of vim"
> endif
> endfu

Yeah, that doesn't work. Why turn the function reference into a string?
Just don't do that.

--
A year spent in artificial intelligence is enough to make one
believe in God.

/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: