On 11/01/09 02:30, Sean wrote:
> Hello,
>
> Long story short:
>
> let readonly_list = ['0000 AAAA', '0010 BBBB']
> let readonly_pat = "^" . 0010
>
> let my_match_index = match(readonly_list, readonly_pat)
>
> The above result is -1.
> But what I want is 1 (the 2nd item on the list)
>
> It looks that the readonly_pat is "transferred" automatically to
> another string "^8", as string(0010)='8'.
>
> Is it possible to avoid this typical behavior from scripting language?
>
> Thanks
>
> Sean
Use a string in the first place:
:let readonly_pat = '^0010'
or
:let readonly_pat = '^' . '0010'
or
:let i = 10 " not 0010 which is eight
:let readonly_pat = '^' . printf ('%4d', i)
Note that if you generate successive numbers as ... 0007, 0008, 0009,
0010, 0011, ... you'll have problems if you try to treat them later as
octal values, where you'll get ... 007, 010, 011, 010, 011, ...
Best regards,
Tony.
--
At Group L, Stoffel oversees six first-rate programmers, a managerial
challenge roughly comparable to herding cats.
-- The Washington Post Magazine, 9 June, 1985
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---