On Sun, Mar 15, at 02:08 Dasn wrote:
>
> On 14/03/09 17:04 +0200, Agathoklis D. Hatzimanikas wrote:
> > On Sat, Mar 14, at 06:27 Dasn wrote:
> > >
> > > Hi,
> > > :h catch-interrupt
> > > shows an example of catching interrupts, but it works not as it was
> > > described. The document says:
> > >
> > > > If you press CTRL-C at the prompt, the script is terminated.
> > >
> > > But the problem is: when I press CTRL-C at the prompt, the script is not
> > > terminated, instead, it will give you another prompt.
> > >
> > > How to catch the interrupts at 'input()' prompt?
> >
> > You can surround the try/endtry block with another try/endtry
> > and use a catch to insert a break statement so you can get out of the
> > loop.
> >
>
> Thanks for your reply, but I'm still not sure where to insert the
> another try/endtry :)
Sorry,
Here is how I've made my test:
function! TASK1()
sleep 10
endfunction
function! TASK2()
sleep 20
endfunction
function! Test()
while 1
try
let command = input("Type a command: ")
try
if command == ""
continue
elseif command == "END"
break
elseif command == "TASK1"
call TASK1()
elseif command == "TASK2"
call TASK2()
else
echo "\nIllegal command:" command
continue
endif
catch /^Vim:Interrupt$/
echo "\nThis is the nested try/catch/endtry"
echo "Command interrupted"
endtry
catch /^Vim:Interrupt$/
echo "\nInput interrupted"
break
endtry
endwhile
endfunction
:call Test()
> Dasn
Regards,
Ag.
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---