Mix string and float attributes in point wrangle

   5357   5   2
User Avatar
Member
951 posts
Joined: April 2008
Offline
Lets say I have:

@crowd = 1 – float or integer
@place = “$hip/$OS/crowd_” – string

I want to end up with:

“$hip/$OS/crowd_1” – the one in the end will vary according to my crowd attribute.

The problem is that I couldn't figure how to mix them in a single string variable in point wrangle sop like:

s@path = @place+@crowd – it doesn't work!

How can I mix them?

I hope it makes sense, thanks in advance.
https://vimeo.com/user2163076 [vimeo.com]
User Avatar
Member
8597 posts
Joined: July 2007
Offline
either by converting integer to string with itoa() function
s@path = s@place + itoa(i@crowd);

or using sprintf() function:
s@path = sprintf(“%s%d”, s@place, i@crowd);

or if crowd number is a float and you want to keep fractional part
s@path = sprintf(“%s%f”, s@place, f@crowd);
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
951 posts
Joined: April 2008
Offline
Thanks!

You rock!
https://vimeo.com/user2163076 [vimeo.com]
User Avatar
Member
951 posts
Joined: April 2008
Offline
Just one more question:ops:

Do you know how I can put padding on numbers in the point wrangle? I tried to use padzero expression but I don know how to use it in the wrangle sop.
https://vimeo.com/user2163076 [vimeo.com]
User Avatar
Member
8597 posts
Joined: July 2007
Offline
you can define pading in sprintf() directly by putting 0n between % and d
like
s@path = sprintf(“%s%04d”, s@place, i@crowd);
will pad your integer crowd attrib to 4 characters

you can read about it in docs
http://www.sidefx.com/docs/houdini12.5/vex/functions/printf [sidefx.com]
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
951 posts
Joined: April 2008
Offline
Thanks dude!
https://vimeo.com/user2163076 [vimeo.com]
  • Quick Links