On Mi, 31 Dez 2025, Mark Manning wrote:
> Hi again Christian!
>
> I am back with another wierdo problem.
>
> Here is the code:
>
> "
> " Make a new filename (ie: full file name PLUS .(high_num+1)
> " In other words - make a new filename with the backup number one
> " higher than the highest backup number. Example A.BOB;00001
> "
> echo "High_num = " . high_num
> let high_num = high_num + 1
> echo "High_num = " . high_num
> let ext = printf("%05d", high_num )
> echo "High_num = " . high_num
> echo "ext = " . ext
> let new_path = expand("%:p") . ";" . ext
> "
> " Now save the file to the new file name we just made.
> "
> echo "new_path = " . new_path
>
> And here is the output (I haven't included all of the output - only
> from this point).
>
> High_num = 00010
> High_num = 9
> High_num = 9
> ext = 00009
> new_path = D:\My Programs\PHP\Fix Paper Types\fixpapers.
> php;00009
>
> As you can see, "High_num" is originally set to "00010". (Actual
> variable name is "high_num".) Anyway, I add one to that number and Vim
> changes the number to "9". I have tried using:
>
> let high_num += 1
> and
> let ++high_num <---Got an error doing this
> and
> let high_num++ <---Got an error doing this too
> and
> let high_num = high_num + 1
>
> and I just keep getting that high_num has decremented by one. I'm using
> version 9.1. Should I upgrade to a higher version of Vim? Thanks ahead
> of time for responsing. I is after 2:00am here so I've got to go to
> bed. Been working on this all day trying anything I could think of.
>
> Mark
> PS: If you want the source code I can zip it up and send it. Simple
> script called decvers.vim. (DEC VERSion - probably should rename it
> to something like Upgrade_version.vim or maybe Make_backup.vim. I'm
> basing it on the old DEC 11/780 system where every time you edited a
> file it made a backup of the file and add the next higher number
> to the end as ";#####". Earlier version numbers are older
> than the bigger version numbers.)
You can include the script verbose on the list, don't need to send it to
me. So the whole list audience has a chance to chime in.
My guess is the value is seen as octal, and therefore Vim is increments
it in octal mode (00010 -> 8 decimal).
Instead of incrementing a string value, I'd recommend to perform the
actual arithmetics using a decimal number and then use printf() to
convert it into a string value.
Thanks,
Christian
--
The people rule.
--
--
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 visit
https://groups.google.com/d/msgid/vim_use/aVT7N2dFqNeLPaAr%40256bit.org.