why doesnt this work?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

why doesnt this work?

John Doe-4
I suspect vim does not convert s:numAlarms to numeric
form?

fun! s:SetAlarm(time)
  let s:numAlarms=s:numAlarms+1
  let s:alarm{s:numAlarms}=substitute(a:time,
":[0-9]*", "", "")*60
  let
s:alarm{s:numAlarms}=s:alarm{s:numAlarms}+substitute(a:time,
"^..:", "", "")
  let
s:alarm{s:numAlarms}=s:alarm{s:numAlarms}+localtime()
  if s:alarm{s:numAlarms} < localtime()
    unlet s:alarm{s:numAlarms}
    let s:numAlarms=s:numAlarms-1
  endif
endf



               
____________________________________________________
Yahoo! Sports
Rekindle the Rivalries. Sign up for Fantasy Football
http://football.fantasysports.yahoo.com
Reply | Threaded
Open this post in threaded view
|

Re: why doesnt this work?

Altukhou Yury
Hello John,
        It seeps to me that it works as expected.
It dosn't work correctly for me because I used:
command! SetAlarm :call s:SetAlarm(<f-args>)

and then :SetAlarm "12:20"
,so it was equvolent to
call s:SetAlarm("\"12:20\"")
and after substitution you get astring '"12"' instead of '12' so it
converted to number 0.
          Maybe you do the same.
Saturday, June 18, 2005, 11:02:25 PM, you wrote:

JD> I suspect vim does not convert s:numAlarms to numeric
JD> form?

JD> fun! s:SetAlarm(time)
JD>   let s:numAlarms=s:numAlarms+1
JD>   let s:alarm{s:numAlarms}=substitute(a:time,
JD> ":[0-9]*", "", "")*60
JD>   let
JD> s:alarm{s:numAlarms}=s:alarm{s:numAlarms}+substitute(a:time,
JD> "^..:", "", "")
JD>   let
JD> s:alarm{s:numAlarms}=s:alarm{s:numAlarms}+localtime()
JD>   if s:alarm{s:numAlarms} < localtime()
JD>     unlet s:alarm{s:numAlarms}
JD>     let s:numAlarms=s:numAlarms-1
JD>   endif
JD> endf



               
JD> ____________________________________________________
JD> Yahoo! Sports
JD> Rekindle the Rivalries. Sign up for Fantasy Football
JD> http://football.fantasysports.yahoo.com



--
Best regards,
 Wind                            mailto:[hidden email]