Forums > MaxMSP

leading zero and setting text in textedit

September 2, 2011 | 6:53 pm

I would like to "set" the contents of a textedit object with a set message, like [set hello]. But the message I would like to set needs to be enclosed in quotes – it is a numeric string that starts with zero – "012". However when I try to do [set "0123"], it includes the quotes in the textedit object box. How do I get rid of the quotes, while preserving the leading zero?

– Pasted Max Patch, click to expand. –

September 2, 2011 | 8:13 pm

I’m not sure you can, although there may be some sort of flaming hoop you could jump through that would get you close. Max doesn’t preserve leading zeros in numbers, and symbols get the quotes, if there’s any ambiguity (which there is in this case because the symbol is just a number.) If this is just for display, you could use a non-breaking flaming hoop, er… non-breaking space to make the number a symbol without the quotes:

– Pasted Max Patch, click to expand. –

September 2, 2011 | 9:53 pm

Thanks Chris – that’s a good hack! But I perhaps distilled my *real* problem down too simply. Attached is what I really want to do – I’m trying to constrain the input into a textedit to just 10 characters, all of which must be digits. It works wonderfully – except for the fact that you cannot have a leading zero, which it needs to be able to do. Any ideas?

– Pasted Max Patch, click to expand. –

September 2, 2011 | 10:15 pm

How are you going to use this "string?" The problem lies in Max’s typing rules, and depending upon what you’re planning on doing with them, I’m not sure you can get around them


September 2, 2011 | 11:10 pm

Well, eventually it gets sent to a Java object, where of course I can manipulate it at will. I do think this approach may be a losing battle…

Is there a jsui text entry object floating around out there?


September 3, 2011 | 12:28 am

Why not just let it have quotes in the max world, and get rid of them in the Java world?


September 3, 2011 | 1:01 am

Cuz I think it looks ugly (this is going into a commercial app), and will likely confuse my users, since that’s not what they typed…


September 3, 2011 | 1:15 am

jhno to the rescue, with LCD!

http://cycling74.com/toolbox/jhno-lcdterm/


Viewing 8 posts - 1 through 8 (of 8 total)