jacmac 2 Posted March 21, 2013 If I have this define: #define OLIVEDRAB '#6B8E23' How do I get '#6B8E23' into a string, for example: _staticmsg = OLIVEDRAB; hintC _staticmsg; does not display '#6B8E23', instead it displays 6B8E23. Wrapping quotes around the constant results in the constant not being replaced with the #define, so I get OLIVEDRAB instead of '#6B8E23'. Are my defines bad for what I'm trying to do or is there a method to get the whole defined constant (including the ' 's) into a string variable? Share this post Link to post Share on other sites
skimmer8824 1 Posted March 21, 2013 Try format["%1",OLIVEDRAB]; Share this post Link to post Share on other sites
jacmac 2 Posted March 21, 2013 That doesn't work either. Share this post Link to post Share on other sites
jacmac 2 Posted March 21, 2013 Is this not possible? Share this post Link to post Share on other sites
tonic-_- 53 Posted March 21, 2013 #define OLIVEDRAB '#6B8E23' hint format["%1", str(OLIVEDRAB)]; That might work? the command str will make it into a string and wrap the " around it. Share this post Link to post Share on other sites
Tajin 349 Posted March 21, 2013 What about this: #define OLIVEDRAB "'#6B8E23'" hintC OLIVEDRAB; Share this post Link to post Share on other sites
jacmac 2 Posted March 21, 2013 I like the str(OLIVEDRAB) idea, I had not thought of it and will try it out. #define OLIVEDRAB "'#6B8E23'" Wouldn't work out because there are a number of situations where the constant does not need to go into a string variable. I could have two versions of the define, one with and one without the quotes, but I would like to avoid that if possible. Share this post Link to post Share on other sites
jacmac 2 Posted March 22, 2013 (edited) Unfortunately str (OLIVEDRAB) doesn't work either. It produces 6B8E23 missing both ' and #. It also appears that # causes some issues. I tried removing the ' from the #define so that the define looked like this: #define OLIVEDRAB #6B8E23 What str (OLIVEDRAB) produces in that case is simply 6. A #define is not handled as expected if is a string with ' and # also causes issues with preprocessing. As a side note #define OLIVEDRAB "'#6B8E23'" does work, so I added a whole set of new #defines with RGB_colorname "'#xxxxxx'" Edited March 22, 2013 by Jacmac Share this post Link to post Share on other sites