how to get var of main object from handler function

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

how to get var of main object from handler function

Ni Va

Using dict of functions as objects, I don't happen to retrieve from job handler cmdlauncher#exit_cb the var obj._jobi  " Job index.

Is there anyway to retrieve this var's value without setting it as global ?

" Use Case
        let x = cmdlauncher#new()

        call x.add_cmd(cmd1)
        call x.add_cmd(cmd2)

        call x.showcmds()
        call x.startjob()        

"/////////////// objects

function! cmdlauncher#new()  "{{{
        let obj = {}
        let obj._cmds = [] " Job command
        let obj._jobs = [] " Job object
        let obj._jobi = 0  " Job index         <<<<< how to access it from handler

        function! obj.startjob() "{{{
                        let cmd = 'cmd /k '.self._cmds[self._jobi]

                        call add (self._jobs, job_start(cmd, {
                        \ 'exit_cb'  : 'cmdlauncher#exit_cb',
                        \ 'close_cb' : 'cmdlauncher#close_cb',
                        \ 'callback' : 'cmdlauncher#callback'
                                                \ })
                        let ch = job_getchannel(self._jobs[-1])

        endfunction "}}}

    return obj

function! cmdlauncher#exit_cb(job, status) "{{{
                echomsg "job exit with : ".string(a:job.' '.a:status)
>>>>>> echomsg  self._jobi  "<< KO
        catch E716
                " No-op if data isn't ready
endfunction "}}}  


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

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 [hidden email].
For more options, visit

cmdlauncher.vim (1K) Download Attachment
backup.vim (915 bytes) Download Attachment