padzero in vex?

   15065   7   2
User Avatar
Member
205 posts
Joined: Dec. 2009
Offline
Hi,

is there an equivalent for h-script's padzero in vex (attribute wrangle sop)? I couldn't find anything related in the docs…

Thanks,
Marc
User Avatar
Member
402 posts
Joined: June 2014
Offline
EDIT: Embarrassing code snippet removed for the sake of clarity… please see sane response below!
Edited by friedasparagus - May 2, 2018 07:49:11
Henry Dean
User Avatar
Staff
2590 posts
Joined: July 2005
Offline
This might be a little easier
string
padzero(int n; int v)
{
    return sprintf("%*0d", n, v);
}

cvex
main()
{
    printf("%s\n", padzero(5, 126));
    printf("%s\n", padzero(5, 23));
    printf("%s\n", padzero(1, 23));
}
User Avatar
Member
402 posts
Joined: June 2014
Offline
hahaha! That's quite hilarious

Note to self… Never offer coding advice with a sore head!
Henry Dean
User Avatar
Member
1737 posts
Joined: May 2006
Offline
Can't just use %04d?

s@name = sprintf('%04d',@Frame);
http://www.tokeru.com/cgwiki [www.tokeru.com]
https://www.patreon.com/mattestela [www.patreon.com]
User Avatar
Member
205 posts
Joined: Dec. 2009
Offline
Great, thanks!

I should really start to learn regex.

Cheers
User Avatar
Member
8532 posts
Joined: July 2007
Offline
bollili
I should really start to learn regex.
while regex is useful, above mentioned syntax is not regex though, more like string formatting, which, similar to regex, can have some differences among programing languages, here is VEX one:
http://www.sidefx.com/docs/houdini/vex/functions/printf.html [www.sidefx.com]
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
205 posts
Joined: Dec. 2009
Offline
Hey tamte, this push into the right direction ist highly appreciated!
Thank you
  • Quick Links