Hi Bram,
I was inspired by testdir/test_vim9script...vim and write these lines.
I wonder how can this job can be monitored during its running life maybe
by callback or another job.
"
# Zip command line
@z = stampedDir .. archiveName
var archive_cmd: string = sevenZ.exe .. sevenZ.exclusion .. ' a "' .. @z
.. '" "' .. archiveSourcePath .. '"' .. sevenZ.compression
# Zip's job
var jobid: job
var source: list<number>
def Out_cb(...l: any)
eval [][0]
enddef
def Exit_cb(...l: any)
sleep 1m
source += l
echomsg 'Exiting ' .. string(l) .. ' ' .. string(@z)
enddef
jobid = job_start(archive_cmd, { out_cb: Out_cb, exit_cb: Exit_cb, mode:
'raw', timeout: 30000 } )
echomsg 'jobid: ' .. string(jobid)
"
Le vendredi 19 mars 2021 à 20:13:46 UTC+1, Bram Moolenaar a écrit :
>
> 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 -- [email protected] -- 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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_use/df1c4bb3-ddae-49ab-9c94-c6415135625dn%40googlegroups.com.