[PD] To divide a number in random parts

Mathieu Bouchard matju at artengine.ca
Sat Mar 5 04:07:27 CET 2011

```On Fri, 4 Mar 2011, Caio Barros wrote:

> Oh yes, we are saying the same thing. Sorry for the comma, I always
> forget that.

You shouldn't be sorry about the comma. Be proud about the comma :)

> Even in pd sometimes I keep trying to write 0,25 in a number box and get
> angry because it doesn't work.

This means pd needs some help with it. Just apply this change to pd, and
it will convert commas to periods :

Index: g_text.c
===================================================================
--- g_text.c	(révision 15012)
+++ g_text.c	(copie de travail)
@@ -714,7 +714,7 @@
x->a_buf[len] = c;
x->a_buf[len+1] = 0;
goto redraw;
-        }
+        } else if (c == ',') strcpy(x->a_buf+len,".");
}
return;
redraw:
Index: g_numbox.c
===================================================================
--- g_numbox.c	(révision 15012)
+++ g_numbox.c	(copie de travail)
@@ -714,12 +714,12 @@
sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update);
return;
}
-    if(((c>='0')&&(c<='9'))||(c=='.')||(c=='-')||
+    if(((c>='0')&&(c<='9'))||(c=='.')||(c=='-')||(c==',')||
(c=='e')||(c=='+')||(c=='E'))
{
if(strlen(x->x_buf) < (IEMGUI_MAX_NUM_LEN-2))
{
-            buf[0] = c;
+            buf[0] = c==','?'.':c;
strcat(x->x_buf, buf);
sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update);
}

> One more thing. How hard it is to make possible for the user to choose
> between the random output that you already made and to sort that output
> from the smallest to longest duration and vice-versa?

[#sort] can sort any list of numbers very quickly.

_______________________________________________________________________
| Mathieu Bouchard ---- tél: +1.514.383.3801 ---- Villeray, Montréal, QC
```