Change Dot in Float to Comma
Hi folks,
simple question, but hard to solve.
example:
theres a floatnum, eg. 3.132 . now i want to print that
floatnum but i dont wanna print 3.132, i wanna print 3,132.
i just want to substitute the dot with the comma.
thanks for your help,
kind regards
Does the result have to be printed by flonum or would an abstraction/bpatcher using textedit or lcd be sufficient?
I'm not sure why, but I can't get regexp to do this properly. It should be a really simple *regexp "(\.) @substitute ,"* but it won't replace with the comma..........anything else in place of the comma works fine.
*regexp (\.) @substitute why_won't_this_work* for example.....
Hopefully someone with more regexp experience will explain why that is, because I must be doing it wrong.
For the record, I've tried *regexp (\.) "@substitute ,"* and *regexp (\.) @substitute ,* as well the latter of which includes the backslash in the substitution, however no backslash results in an automatic correction to @substitute, which will also not work.
Sorry to not be of more help, this should be simple to sort out!
This is a surprisingly hard problem in many languages, further complicated by the fact that commas are special characters in in Max (and many languages.)
You might want to try [prepend set]-ing it into a comment rather than a message box if it is only for display purposes as comments don't have to obey all the tricky max laws that messages do.
lh
Right you are Luke:
slice it, then replace the dot with the comma using ascii (atoi and itoa)
With all the above examples you get an error on decimal points beginning with a zero. Beginning zeroes are all truncated.
And there's a space after the comma, so you get two symbols and not a unique one
With all the above examples you get an error on decimal points beginning with a zero
Hi there!
To make this short I want to get rid of a comma at the end of a message that is set with regexp @substitute. It's a long shot but I am trying to work around a boolean restriction with the maxurl object and the json format. See https://cycling74.com/forums/remove-reverse-solidus-quotation-mark-message-dict-serialize-mode-json-dict-pack
But I get stuck with a comma at the end of my instruction.
ThatLastComma: { "on":true, "hue":33333, "sat":200, "bri":127, }
How can I get rid of the last comma? Thank you.
You seem to be adding the comma at the end of your regexp argument. Try removing \\, from the end of the expression.
The thing of it is that I need commas to separate the value pairs, but the last one gives me a json format error with the maxurl object. I trying to figure out a way to iterate it only three times.
Try this:
OK, I think I understand.
regexp (.+)\\, will give you everything before the last comma, out the 2nd outlet. Then all you have to do is append a bracket at the end and you got it. Like this:
Hi METAMAX!
Nice regexp! I reordered the object flow and It does exactly what I need.Thanks!
Good to hear, my friend. All the best with your project.
Best Solution is [regexp \\. @substitute \\,]