leading zero and setting text in textedit

Dan Nigrin's icon
Max Patch
Copy patch and select New From Clipboard in Max.

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?

Chris Muir's icon
Max Patch
Copy patch and select New From Clipboard in Max.

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:

Dan Nigrin's icon
Max Patch
Copy patch and select New From Clipboard in Max.

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?

Chris Muir's icon

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

Dan Nigrin's icon

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?

Chris Muir's icon

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

Dan Nigrin's icon

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...

Dan Nigrin's icon