Grasshopper

algorithmic modeling for Rhino

I'm struggling with the syntax for the Format(s[,a,b,c...]) function. If I want to get a result, "Distance= 20 feet"  I'm expecting that I would write Format("Distance = ?x? feet",x) with the appropriate delimiter where I've placed question marks and x being the input value to the function component.  I can't figure out what the delimiter is.  Have I made some fundamental error in the use of this function?

Thanks.

Chris

Views: 6584

Replies to This Discussion

String formatting follows (calls) the .Net string formatting functions. ( method, formatting overview or nice introduction ).

 

In your case, this should do:

Format("Distance = {0} feet", x)

 

If you had two inputs:

Format("Distance = {0} {1}", x, unit)

 

- Giulio

____________

giulio@mcneel.com

McNeel Europe, Barcelona

Thank you.

Chris

That is a neat solution

Hi there,

I have just seen your post, and I don't know if you found a solution of not, anyway here is my two cents solution




Or {0:0.##} to allow for two decimal placed to be included, but only if they're not zero. Or {0:0.00##} to always include two decimals, but allow four if they are non-zero.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service