magneto Posted June 16, 2013 Share Posted June 16, 2013 (edited) Hi, The title is not very clear but I have a string attribute where I want to modify its values by using basic arithmetic. The string attribute looks like this: attribute name = mypathattribute value = "C:/Textures/bump"[/CODE]I want to replace "bump" with "disp", and add 1, 2, 3 to it as a suffix with ".jpg":[CODE]"C:/Textures/disp1.jpg""C:/Textures/disp2.jpg" (next attribute)"C:/Textures/disp3.jpg" (next attribute)[/CODE]I tried this but the number 1 is added as a string, and I don't know how to force it to be evaulated as an integer:[CODE]`strreplace($MYPATH, "bump", "disp" + ($PT % 3) + 1 + ".jpg")`[/CODE]The modulo returns, 0, 1, and 2 so I need to add 1 to it, but it ends up as 01, 11, 21 due to string concatenation.Any idea how to evaluate this as an integer?Thanks Edited June 16, 2013 by magneto Quote Link to comment Share on other sites More sharing options...
Guest mantragora Posted June 17, 2013 Share Posted June 17, 2013 For example you can add () around ($PT % 3) + 1 `strreplace($MYPATH, "bump", "disp" + (($PT % 3) + 1) + ".jpg")` so it gets evaluated as one expression first. 1 Quote Link to comment Share on other sites More sharing options...
magneto Posted June 17, 2013 Author Share Posted June 17, 2013 Thanks that worked. I am getting weird modulo results for some reason though. 0, 0, 2, 0, 2, 1, 1, for 0-6. Not sure why that is. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.