Ni Va wrote:
> I got not recognized function handler starting a job in vim9script.
>
>
> *"*
> *Error detected while processing function <SNR>24_ZipUpDir:*
> *line 60:*
> *E700: Unknown function: MyHandlerCallback *
> "
>
> And this is the vim9script:
>
> "
> vim9script
>
> var jobid: job
> var options: dict<any>
>
> # Job Part {{{
> def MyHandlerExit(channel: channel, msg: string): void
> job_stop(jobid)
> echomsg 'Exiting ' .. string(msg) .. ' ' .. string(@z)
>
> def MyHandlerCallback2(channel: channel, msg: string)
> echomsg string(msg)
> enddef
>
> options = { "callback": function('MyHandlerCallback2') }
> job_start(cmd, options)
> enddef
>
> def MyHandlerCallback(channel: channel, msg: string): void
> echomsg string(msg)
> enddef
>
> options = { 'callback': function('MyHandlerCallback'), 'exit_cb':
> function('MyHandlerExit'), 'timeout': 30000 }
> jobid = job_start(cmd, options) | echomsg 'jobid: ' .. string(jobid)
>
> "
"cmd" is not defined. But you probably want to remove function() and
use MyHandlerCallback directly. The function will be defined
script-local, and using it as a string won't work inside job-start().
You don't need the ": void" for the function, not returning anything is
the default.
--
Contrary to popular belief, it's often your clothing that gets promoted, not
you.
(Scott Adams - The Dilbert principle)
/// 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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/202103191913.12JJDX3a1595047%40masaka.moolenaar.net.
No comments:
Post a Comment