logic problem with binop & conditions

Nov 19, 2007 at 9:11pm

logic problem with binop & conditions

Hi everyone,

Here’s my problem.
I have a radiogroup with 4 check boxes.
if I click on the first check box, I want 1
if I click on the second check box, I want 2
and so on.

Now, if the first & second boxes are checked, I want 5.
and if the first & third boxes are checked then I want 6,
and if the first & fourth boxes are checked, then I want 7.

etc.

I have fifteen possible combinations with these four check boxes.
Each combination must give one unique result.

I tryed many solutions . The “right to left” one is the best I found, but if you look at the Max Window you will see useless datas.

If you have a solution from a similar problem or an idea …

Here’s my patch.

max v2;
#N vpatcher 11 50 837 710;
#P origin 0 -22;
#P window setfont “Sans Serif” 9.;
#P newex 424 559 47 196617 s 2menu;
#P window setfont “Sans Serif” 18.;
#N vpatcher 20 74 663 432;
#P window setfont “Sans Serif” 9.;
#P message 133 271 414 196617 if $i 1==1 && 0 then 5 else if 0 ==1 && 0 == 1 then 6 else if 0 == 1 && 0 == 1 then 7;
#P newex 133 246 62 196617 prepend set;
#P user radiogroup 143 50 18 76;
#X size 4;
#X offset 20;
#X inactive 0;
#X itemtype 1;
#X flagmode 0;
#X set 0 0 0 0;
#X done;
#P number 50 204 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 143 131 76 196617 unpack 0 0 0 0;
#P window linecount 2;
#P newex 50 165 295 196617 if $i1 == 1 then 1 else if $i 1==1 && $i2==1 then 5 else if $i1 ==1 && $i3 == 1 then 6 else if $i1 == 1 && $i4 == 1 then 7;
#P window linecount 1;
#P comment 161 221 307 196617 I saw this syntaxe somewhere (…else if..) but does not work here;
#P connect 2 0 1 0;
#P connect 1 0 3 0;
#P connect 1 0 5 0;
#P connect 5 0 6 0;
#P connect 4 0 2 0;
#P connect 2 1 1 1;
#P connect 2 2 1 2;
#P connect 2 3 1 3;
#P pop;
#P newobj 138 122 199 196626 p if then else solution;
#N vpatcher 121 44 1174 757;
#P window setfont “Sans Serif” 9.;
#P newex 295 567 32 196617 print;
#P newex 355 527 47 196617 r 2menu;
#P number 355 590 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont “Sans Serif” 18.;
#P user ubumenu 355 552 208 196626 0 1 1 0;
#X add off;
#X add matrice 1;
#X add matrice 2;
#X add matrice 3;
#X add matrice 4;
#X add matrice 1+2;
#X add matrice 1+3;
#X add matrice 1+4;
#X add matrice 2+3;
#X add matrice 2+4;
#X add matrice 3+4;
#X add matrices 1+2+3;
#X add matrices 1+2+4;
#X add matrices 1+3+4;
#X add matrices 2+3+4;
#X add matrices 1+2+3+4;
#X prefix_set 0 0 0;
#P window setfont “Sans Serif” 9.;
#P window linecount 36;
#P comment 858 278 74 196617 logic problem with conditions;
#P window linecount 1;
#P newex 233 404 35 196617 bondo;
#P newex 327 313 35 196617 bondo;
#P newex 421 314 35 196617 bondo;
#P newex 421 335 27 196617 &&;
#P user led 498 255 17 17 0 150;
#P user led 436 255 17 17 0 150;
#P user led 561 255 17 17 0 150;
#P comment 578 255 37 196617 1 et 4;
#P comment 514 255 37 196617 1 et 3;
#P comment 451 255 33 196617 1 et 2;
#P newex 493 312 35 196617 bondo;
#P newex 493 333 27 196617 &&;
#P newex 546 311 35 196617 bondo;
#P user led 657 256 17 17 0 150;
#P user led 632 235 17 17 0 150;
#P comment 674 256 37 196617 2 et 4;
#P comment 651 238 37 196617 2 et 3;
#P user led 714 236 17 17 0 150;
#P comment 734 238 40 196617 3 et 4;
#P user led 890 212 17 17 0 150;
#P comment 907 212 17 196617 4;
#P user led 853 212 17 17 0 150;
#P comment 870 213 17 196617 3;
#P user led 818 213 17 17 0 150;
#P comment 835 213 17 196617 2;
#P user led 781 213 17 17 0 150;
#P comment 798 213 17 196617 1;
#N vpatcher 10 59 337 344;
#P outlet 152 146 15 0;
#P window setfont “Sans Serif” 9.;
#P newex 107 172 47 196617 s 2menu;
#P newex 50 94 32 196617 sel 1;
#P newex 50 116 29 196617 t 10;
#P newex 50 50 27 196617 &&;
#P inlet 67 30 15 0;
#P inlet 50 30 15 0;
#P connect 0 0 2 0;
#P connect 2 0 4 0;
#P connect 4 0 3 0;
#P connect 1 0 2 1;
#P connect 3 0 5 0;
#P connect 2 0 6 0;
#P pop;
#P newobj 715 216 30 196617 p 3+;
#N vpatcher 10 59 327 230;
#P window setfont “Sans Serif” 9.;
#P newex 109 50 27 196617 &&;
#P newex 57 50 27 196617 &&;
#P inlet 126 30 15 0;
#P inlet 74 30 15 0;
#P inlet 57 30 15 0;
#P inlet 109 30 15 0;
#P outlet 50 92 15 0;
#P outlet 112 95 15 0;
#P connect 6 0 1 0;
#P connect 3 0 6 0;
#P connect 4 0 6 1;
#P connect 2 0 7 0;
#P connect 7 0 0 0;
#P connect 5 0 7 1;
#P pop;
#P newobj 632 213 53 196617 p 2+;
#N vpatcher 10 59 339 252;
#P window setfont “Sans Serif” 9.;
#P newex 151 50 27 196617 &&;
#P newex 98 51 27 196617 &&;
#P newex 57 52 27 196617 &&;
#P inlet 168 30 15 0;
#P inlet 57 32 15 0;
#P inlet 98 31 15 0;
#P inlet 151 30 15 0;
#P inlet 74 32 15 0;
#P inlet 115 31 15 0;
#P outlet 151 72 15 0;
#P outlet 57 74 15 0;
#P outlet 98 73 15 0;
#P connect 7 0 9 0;
#P connect 9 0 1 0;
#P connect 4 0 9 1;
#P connect 6 0 10 0;
#P connect 10 0 0 0;
#P connect 3 0 10 1;
#P connect 5 0 11 0;
#P connect 11 0 2 0;
#P connect 8 0 11 1;
#P pop;
#P newobj 476 225 79 196617 p 1+;
#N vpatcher 10 59 313 338;
#P window setfont “Sans Serif” 9.;
#P newex 100 165 47 196617 s 2menu;
#P newex 157 73 32 196617 sel 1;
#P newex 123 73 32 196617 sel 1;
#P newex 89 73 32 196617 sel 1;
#P newex 55 73 32 196617 sel 1;
#P newex 155 93 21 196617 t 4;
#P newex 122 93 21 196617 t 3;
#P newex 87 93 21 196617 t 2;
#P newex 55 93 21 196617 t 1;
#P inlet 159 30 15 0;
#P inlet 122 30 15 0;
#P inlet 87 31 15 0;
#P inlet 50 31 15 0;
#P connect 0 0 8 0;
#P connect 8 0 4 0;
#P connect 9 0 5 0;
#P connect 1 0 9 0;
#P connect 7 0 12 0;
#P connect 6 0 12 0;
#P connect 5 0 12 0;
#P connect 4 0 12 0;
#P connect 10 0 6 0;
#P connect 2 0 10 0;
#P connect 11 0 7 0;
#P connect 3 0 11 0;
#P pop;
#P newobj 824 239 53 196617 p 1;
#P newex 197 298 32 196617 sel 1;
#P newex 159 299 32 196617 sel 1;
#P newex 122 299 32 196617 sel 1;
#P newex 83 298 32 196617 sel 1;
#P newex 45 299 32 196617 sel 1;
#P newex 417 399 32 196617 sel 1;
#P newex 454 399 32 196617 sel 1;
#P newex 491 399 32 196617 sel 1;
#P newex 528 399 32 196617 sel 1;
#P newex 236 464 32 196617 sel 1;
#P newex 234 484 29 196617 t 15;
#P newex 528 418 29 196617 t 14;
#P newex 491 418 29 196617 t 13;
#P newex 457 418 29 196617 t 12;
#P newex 423 418 29 196617 t 11;
#P newex 197 320 21 196617 t 9;
#P newex 160 320 21 196617 t 8;
#P newex 122 322 21 196617 t 7;
#P newex 83 321 21 196617 t 6;
#P newex 45 322 21 196617 t 5;
#P newex 218 548 47 196617 s 2menu;
#P user led 546 356 17 17 0 150;
#P comment 569 356 37 196617 2 3 4;
#P newex 546 332 27 196617 &&;
#P comment 460 355 34 196617 1 2 4;
#P user led 494 355 17 17 0 150;
#P comment 388 356 34 196617 1 3 4;
#P user led 421 356 17 17 0 150;
#P comment 339 356 34 196617 1 2 3;
#P user led 324 356 17 17 0 150;
#P user led 235 444 17 17 0 150;
#P comment 250 446 43 196617 1 2 3 4;
#P newex 235 425 27 196617 &&;
#P newex 327 334 27 196617 &&;
#P newex 509 143 76 196617 unpack 0 0 0 0;
#P user radiogroup 509 61 18 76;
#X size 4;
#X offset 20;
#X inactive 0;
#X itemtype 1;
#X flagmode 0;
#X set 1 1 1 1;
#X done;
#P window setfont “Sans Serif” 14.;
#P window linecount 0;
#P comment 248 100 149 196622 right to left solution;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P comment 853 318 100 196617 Hi everyone , Here’s my problem. I have a radiogroup with 4 check boxes. if I click on the first check box , I want 1 if I click on the second check box , I want 2 and so on. Now , if the first & second boxes are checked , I want 5. and if the first & third boxes are checked then I want 6 , and if the first & fourth boxes are checked , then I want 7. etc. So I have fifteen possible combinations with these four check boxes , but I don’t achieve my goal. I tryed many solutions without success;
#P connect 63 0 33 0;
#P connect 33 0 18 0;
#P connect 64 0 34 0;
#P connect 34 0 19 0;
#P connect 35 0 20 0;
#P connect 40 0 36 0;
#P connect 36 0 21 0;
#P connect 40 1 37 0;
#P connect 37 0 22 0;
#P connect 27 0 17 0;
#P connect 26 0 17 0;
#P connect 25 0 17 0;
#P connect 24 0 17 0;
#P connect 23 0 17 0;
#P connect 21 0 17 0;
#P connect 22 0 17 0;
#P connect 20 0 17 0;
#P connect 19 0 17 0;
#P connect 18 0 17 0;
#P connect 8 0 68 0;
#P connect 28 0 27 0;
#P connect 68 0 5 0;
#P connect 5 0 7 0;
#P connect 7 0 28 0;
#P connect 68 1 5 1;
#P connect 10 0 68 1;
#P connect 72 0 73 0;
#P connect 4 0 8 0;
#P connect 63 0 67 0;
#P connect 67 0 4 0;
#P connect 67 1 4 1;
#P connect 64 0 67 1;
#P connect 72 0 70 0;
#P connect 70 0 71 0;
#P connect 8 0 32 0;
#P connect 64 0 66 0;
#P connect 66 0 65 0;
#P connect 65 0 10 0;
#P connect 32 0 23 0;
#P connect 39 0 63 0;
#P connect 66 1 65 1;
#P connect 62 0 66 1;
#P connect 10 0 31 0;
#P connect 31 0 24 0;
#P connect 3 0 39 0;
#P connect 3 1 39 1;
#P connect 12 0 30 0;
#P connect 30 0 25 0;
#P connect 63 0 58 0;
#P connect 58 0 57 0;
#P connect 57 0 12 0;
#P connect 39 1 64 0;
#P connect 3 0 39 2;
#P connect 2 0 3 0;
#P connect 58 1 57 1;
#P connect 3 2 39 3;
#P connect 62 0 58 1;
#P connect 3 0 39 4;
#P connect 16 0 29 0;
#P connect 29 0 26 0;
#P connect 3 3 39 5;
#P connect 54 0 56 0;
#P connect 56 0 14 0;
#P connect 14 0 16 0;
#P connect 39 2 62 0;
#P connect 56 1 14 1;
#P connect 55 0 56 1;
#P connect 3 1 40 0;
#P connect 40 0 54 0;
#P connect 3 2 40 1;
#P connect 40 1 55 0;
#P connect 3 1 40 2;
#P connect 3 3 40 3;
#P connect 41 0 51 0;
#P connect 3 2 41 0;
#P connect 3 3 41 1;
#P connect 3 0 43 0;
#P connect 3 1 45 0;
#P connect 43 0 38 0;
#P connect 45 0 38 1;
#P connect 47 0 38 2;
#P connect 3 2 47 0;
#P connect 49 0 38 3;
#P connect 3 3 49 0;
#P pop;
#P newobj 138 81 202 196626 p right to left solution;
#P window setfont “Sans Serif” 9.;
#P newex 35 172 47 196617 r 2menu;
#P number 35 235 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont “Sans Serif” 18.;
#P user ubumenu 35 197 208 196626 0 1 1 0;
#X add off;
#X add matrice 1;
#X add matrice 2;
#X add matrice 3;
#X add matrice 4;
#X add matrice 1+2;
#X add matrice 1+3;
#X add matrice 1+4;
#X add matrice 2+3;
#X add matrice 2+4;
#X add matrice 3+4;
#X add matrices 1+2+3;
#X add matrices 1+2+4;
#X add matrices 1+3+4;
#X add matrices 2+3+4;
#X add matrices 1+2+3+4;
#X prefix_set 0 0
0;
#P window setfont “Sans Serif” 9.;
#P newex 81 235 209 196617 sel 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15;
#P comment 103 563 31 196617 15;
#P comment 103 540 31 196617 14;
#P comment 103 520 31 196617 13;
#P comment 103 500 31 196617 12;
#P comment 103 480 26 196617 11;
#P comment 103 460 22 196617 10;
#P comment 103 440 22 196617 9;
#P comment 103 420 22 196617 8;
#P comment 103 400 22 196617 7;
#P comment 103 380 22 196617 6;
#P comment 103 360 22 196617 5;
#P comment 103 340 22 196617 4;
#P comment 103 320 22 196617 3;
#P comment 103 300 22 196617 2;
#P comment 103 282 22 196617 1;
#P comment 43 564 52 196617 1+2+3+4;
#P comment 45 541 40 196617 2+3+4;
#P comment 45 521 40 196617 1+3+4;
#P comment 45 501 40 196617 1+2+4;
#P comment 45 481 40 196617 1+2+3;
#P comment 45 461 26 196617 3+4;
#P comment 45 441 26 196617 2+4;
#P comment 45 421 26 196617 2+3;
#P comment 45 401 26 196617 1+4;
#P comment 45 381 26 196617 1+3;
#P comment 45 361 26 196617 1+2;
#P comment 45 341 14 196617 4;
#P comment 45 321 14 196617 3;
#P comment 45 301 14 196617 2;
#P comment 45 283 14 196617 1;
#P user led 366 376 17 17 0 150;
#P user led 564 439 17 17 0 150;
#P comment 582 439 37 196617 2 3 4;
#P newex 565 416 27 196617 &&;
#P user led 670 376 17 17 0 150;
#P user led 600 376 17 17 0 150;
#P user led 539 376 17 17 0 150;
#P user led 639 301 17 17 0 150;
#P comment 656 301 17 196617 4;
#P user led 543 301 17 17 0 150;
#P comment 560 301 17 196617 3;
#P user led 447 301 17 17 0 150;
#P comment 464 301 17 196617 2;
#P user led 351 301 17 17 0 150;
#P comment 368 301 17 196617 1;
#P user led 286 376 17 17 0 150;
#P user led 464 376 17 17 0 150;
#P comment 447 439 34 196617 1 2 4;
#P user led 481 439 17 17 0 150;
#P newex 469 416 27 196617 &&;
#P comment 368 439 34 196617 1 3 4;
#P user led 401 439 17 17 0 150;
#P comment 313 439 34 196617 1 2 3;
#P user led 298 439 17 17 0 150;
#P user led 342 496 17 17 0 150;
#P comment 342 498 44 196617 1 2 3 4;
#P newex 342 477 28 196617 &&;
#P newex 384 416 27 196617 &&;
#P newex 324 416 27 196617 &&;
#P newex 599 353 27 196617 &&;
#P comment 617 376 37 196617 2 et 4;
#P comment 557 376 37 196617 2 et 3;
#P newex 547 353 27 196617 &&;
#P comment 433 376 37 196617 1 et 4;
#P newex 428 353 27 196617 &&;
#P comment 375 376 37 196617 1 et 3;
#P newex 367 353 27 196617 &&;
#P comment 688 376 40 196617 3 et 4;
#P newex 661 353 27 196617 &&;
#P comment 303 376 33 196617 1 et 2;
#P newex 297 353 27 196617 &&;
#P newex 438 261 76 196617 unpack 0 0 0 0;
#P user radiogroup 438 176 18 76;
#X size 4;
#X offset 20;
#X inactive 0;
#X itemtype 1;
#X flagmode 0;
#X set 0 1 0 0;
#X done;
#P connect 76 0 74 0;
#P connect 74 0 75 0;
#P fasten 74 0 73 0 40 231 86 231;
#P connect 2 0 27 0;
#P connect 1 0 2 0;
#P connect 14 0 19 0;
#P connect 1 1 2 1;
#P connect 2 0 14 0;
#P connect 6 0 14 1;
#P connect 14 0 16 0;
#P connect 16 0 18 0;
#P connect 1 0 29 0;
#P connect 15 0 16 1;
#P connect 6 0 42 0;
#P connect 1 0 6 0;
#P connect 1 2 6 1;
#P connect 6 0 15 0;
#P connect 8 0 15 1;
#P connect 15 0 21 0;
#P connect 1 0 8 0;
#P connect 0 0 1 0;
#P connect 1 3 8 1;
#P connect 1 1 31 0;
#P connect 8 0 26 0;
#P connect 2 0 23 0;
#P connect 23 0 24 0;
#P connect 8 0 23 1;
#P connect 10 0 36 0;
#P connect 1 2 33 0;
#P connect 1 1 10 0;
#P connect 1 2 10 1;
#P connect 39 0 41 0;
#P connect 36 0 39 0;
#P connect 37 0 39 1;
#P connect 1 1 13 0;
#P connect 13 0 37 0;
#P connect 1 3 13 1;
#P connect 1 3 35 0;
#P connect 1 2 4 0;
#P connect 4 0 38 0;
#P connect 1 3 4 1;
#P pop;

#34671
Nov 19, 2007 at 9:48pm

#P window setfont “Sans Serif” 9.;
#P number 37 264 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 37 231 64 196617 +;
#P newex 91 181 49 196617 +;
#P newex 37 184 32 196617 +;
#P newex 130 147 27 196617 * 8;
#P newex 91 146 27 196617 * 4;
#P newex 59 146 27 196617 * 2;
#P newex 37 114 76 196617 unpack 0 0 0 0;
#P user radiogroup 37 32 18 76;
#X size 4;
#X offset 20;
#X inactive 0;
#X itemtype 1;
#X flagmode 0;
#X set 1 1 1 1;
#X done;
#P connect 7 0 8 0;
#P connect 6 0 7 1;
#P connect 5 0 7 0;
#P connect 4 0 6 1;
#P connect 3 0 6 0;
#P connect 2 0 5 1;
#P connect 1 0 5 0;
#P connect 1 3 4 0;
#P connect 1 2 3 0;
#P connect 1 1 2 0;
#P connect 0 0 1 0;
#P window clipboard copycount 9;

#117379
Nov 19, 2007 at 9:51pm

And I prefer this solution (requires Litter Power Starter Pack on PPC or Windows, needs Litter Pro for UB)

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 37 173 104 196617 pack 0 0 0 0;
#P newex 37 195 86 196617 lp.sigma 0 0 0 0;
#P number 37 264 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 130 147 27 196617 * 8;
#P newex 91 146 27 196617 * 4;
#P newex 59 146 27 196617 * 2;
#P newex 37 114 76 196617 unpack 0 0 0 0;
#P user radiogroup 37 32 18 76;
#X size 4;
#X offset 20;
#X inactive 0;
#X itemtype 1;
#X flagmode 0;
#X set 1 1 1 1;
#X done;
#P connect 7 0 6 0;
#P connect 4 0 7 3;
#P connect 3 0 7 2;
#P connect 2 0 7 1;
#P connect 1 0 7 0;
#P connect 6 0 5 0;
#P connect 1 3 4 0;
#P connect 1 2 3 0;
#P connect 1 1 2 0;
#P connect 0 0 1 0;
#P window clipboard copycount 8;

There’s even a single-external solution if you poke around MaxObjects.

#117380
Nov 19, 2007 at 10:18pm

With Lobjects

#P window setfont “Sans Serif” 9.;
#P number 191 169 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 191 140 33 196617 Lsum;
#P user radiogroup 191 28 18 76;
#X size 4;
#X offset 20;
#X inactive 0;
#X itemtype 1;
#X flagmode 0;
#X set 0 0 0 0;
#X done;
#P newex 191 115 71 196617 Lmult 1 2 4 8;
#P comment 226 65 100 196617 with Lobjects;
#P connect 3 0 4 0;
#P connect 1 0 3 0;
#P connect 2 0 1 0;
#P window clipboard copycount 5;

On 11/19/07 4:11 PM, “Derrick Giscloux” wrote:

>
> Hi everyone,
>
> Here’s my problem.
> I have a radiogroup with 4 check boxes.
> if I click on the first check box, I want 1
> if I click on the second check box, I want 2
> and so on.
>
> Now, if the first & second boxes are checked, I want 5.
> and if the first & third boxes are checked then I want 6,
> and if the first & fourth boxes are checked, then I want 7.
>
> etc.
>
> I have fifteen possible combinations with these four check boxes.
> Each combination must give one unique result.
>
> I tryed many solutions . The “right to left” one is the best I found, but if
> you look at the Max Window you will see useless datas.
>
> If you have a solution from a similar problem or an idea …
>
> Here’s my patch.
>
>
> max v2;
> #N vpatcher 11 50 837 710;
> #P origin 0 -22;
> #P window setfont “Sans Serif” 9.;
> #P newex 424 559 47 196617 s 2menu;
> #P window setfont “Sans Serif” 18.;
> #N vpatcher 20 74 663 432;
> #P window setfont “Sans Serif” 9.;
> #P message 133 271 414 196617 if $i 1==1 && 0 then 5 else if 0 ==1 && 0 == 1
> then 6 else if 0 == 1 && 0 == 1 then 7;
> #P newex 133 246 62 196617 prepend set;
> #P user radiogroup 143 50 18 76;
> #X size 4;
> #X offset 20;
> #X inactive 0;
> #X itemtype 1;
> #X flagmode 0;
> #X set 0 0 0 0;
> #X done;
> #P number 50 204 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P newex 143 131 76 196617 unpack 0 0 0 0;
> #P window linecount 2;
> #P newex 50 165 295 196617 if $i1 == 1 then 1 else if $i 1==1 && $i2==1 then 5
> else if $i1 ==1 && $i3 == 1 then 6 else if $i1 == 1 && $i4 == 1 then 7;
> #P window linecount 1;
> #P comment 161 221 307 196617 I saw this syntaxe somewhere (…else if..) but
> does not work here;
> #P connect 2 0 1 0;
> #P connect 1 0 3 0;
> #P connect 1 0 5 0;
> #P connect 5 0 6 0;
> #P connect 4 0 2 0;
> #P connect 2 1 1 1;
> #P connect 2 2 1 2;
> #P connect 2 3 1 3;
> #P pop;
> #P newobj 138 122 199 196626 p if then else solution;
> #N vpatcher 121 44 1174 757;
> #P window setfont “Sans Serif” 9.;
> #P newex 295 567 32 196617 print;
> #P newex 355 527 47 196617 r 2menu;
> #P number 355 590 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P window setfont “Sans Serif” 18.;
> #P user ubumenu 355 552 208 196626 0 1 1 0;
> #X add off;
> #X add matrice 1;
> #X add matrice 2;
> #X add matrice 3;
> #X add matrice 4;
> #X add matrice 1+2;
> #X add matrice 1+3;
> #X add matrice 1+4;
> #X add matrice 2+3;
> #X add matrice 2+4;
> #X add matrice 3+4;
> #X add matrices 1+2+3;
> #X add matrices 1+2+4;
> #X add matrices 1+3+4;
> #X add matrices 2+3+4;
> #X add matrices 1+2+3+4;
> #X prefix_set 0 0 0;
> #P window setfont “Sans Serif” 9.;
> #P window linecount 36;
> #P comment 858 278 74 196617 logic problem with conditions;
> #P window linecount 1;
> #P newex 233 404 35 196617 bondo;
> #P newex 327 313 35 196617 bondo;
> #P newex 421 314 35 196617 bondo;
> #P newex 421 335 27 196617 &&;
> #P user led 498 255 17 17 0 150;
> #P user led 436 255 17 17 0 150;
> #P user led 561 255 17 17 0 150;
> #P comment 578 255 37 196617 1 et 4;
> #P comment 514 255 37 196617 1 et 3;
> #P comment 451 255 33 196617 1 et 2;
> #P newex 493 312 35 196617 bondo;
> #P newex 493 333 27 196617 &&;
> #P newex 546 311 35 196617 bondo;
> #P user led 657 256 17 17 0 150;
> #P user led 632 235 17 17 0 150;
> #P comment 674 256 37 196617 2 et 4;
> #P comment 651 238 37 196617 2 et 3;
> #P user led 714 236 17 17 0 150;
> #P comment 734 238 40 196617 3 et 4;
> #P user led 890 212 17 17 0 150;
> #P comment 907 212 17 196617 4;
> #P user led 853 212 17 17 0 150;
> #P comment 870 213 17 196617 3;
> #P user led 818 213 17 17 0 150;
> #P comment 835 213 17 196617 2;
> #P user led 781 213 17 17 0 150;
> #P comment 798 213 17 196617 1;
> #N vpatcher 10 59 337 344;
> #P outlet 152 146 15 0;
> #P window setfont “Sans Serif” 9.;
> #P newex 107 172 47 196617 s 2menu;
> #P newex 50 94 32 196617 sel 1;
> #P newex 50 116 29 196617 t 10;
> #P newex 50 50 27 196617 &&;
> #P inlet 67 30 15 0;
> #P inlet 50 30 15 0;
> #P connect 0 0 2 0;
> #P connect 2 0 4 0;
> #P connect 4 0 3 0;
> #P connect 1 0 2 1;
> #P connect 3 0 5 0;
> #P connect 2 0 6 0;
> #P pop;
> #P newobj 715 216 30 196617 p 3+;
> #N vpatcher 10 59 327 230;
> #P window setfont “Sans Serif” 9.;
> #P newex 109 50 27 196617 &&;
> #P newex 57 50 27 196617 &&;
> #P inlet 126 30 15 0;
> #P inlet 74 30 15 0;
> #P inlet 57 30 15 0;
> #P inlet 109 30 15 0;
> #P outlet 50 92 15 0;
> #P outlet 112 95 15 0;
> #P connect 6 0 1 0;
> #P connect 3 0 6 0;
> #P connect 4 0 6 1;
> #P connect 2 0 7 0;
> #P connect 7 0 0 0;
> #P connect 5 0 7 1;
> #P pop;
> #P newobj 632 213 53 196617 p 2+;
> #N vpatcher 10 59 339 252;
> #P window setfont “Sans Serif” 9.;
> #P newex 151 50 27 196617 &&;
> #P newex 98 51 27 196617 &&;
> #P newex 57 52 27 196617 &&;
> #P inlet 168 30 15 0;
> #P inlet 57 32 15 0;
> #P inlet 98 31 15 0;
> #P inlet 151 30 15 0;
> #P inlet 74 32 15 0;
> #P inlet 115 31 15 0;
> #P outlet 151 72 15 0;
> #P outlet 57 74 15 0;
> #P outlet 98 73 15 0;
> #P connect 7 0 9 0;
> #P connect 9 0 1 0;
> #P connect 4 0 9 1;
> #P connect 6 0 10 0;
> #P connect 10 0 0 0;
> #P connect 3 0 10 1;
> #P connect 5 0 11 0;
> #P connect 11 0 2 0;
> #P connect 8 0 11 1;
> #P pop;
> #P newobj 476 225 79 196617 p 1+;
> #N vpatcher 10 59 313 338;
> #P window setfont “Sans Serif” 9.;
> #P newex 100 165 47 196617 s 2menu;
> #P newex 157 73 32 196617 sel 1;
> #P newex 123 73 32 196617 sel 1;
> #P newex 89 73 32 196617 sel 1;
> #P newex 55 73 32 196617 sel 1;
> #P newex 155 93 21 196617 t 4;
> #P newex 122 93 21 196617 t 3;
> #P newex 87 93 21 196617 t 2;
> #P newex 55 93 21 196617 t 1;
> #P inlet 159 30 15 0;
> #P inlet 122 30 15 0;
> #P inlet 87 31 15 0;
> #P inlet 50 31 15 0;
> #P connect 0 0 8 0;
> #P connect 8 0 4 0;
> #P connect 9 0 5 0;
> #P connect 1 0 9 0;
> #P connect 7 0 12 0;
> #P connect 6 0 12 0;
> #P connect 5 0 12 0;
> #P connect 4 0 12 0;
> #P connect 10 0 6 0;
> #P connect 2 0 10 0;
> #P connect 11 0 7 0;
> #P connect 3 0 11 0;
> #P pop;
> #P newobj 824 239 53 196617 p 1;
> #P newex 197 298 32 196617 sel 1;
> #P newex 159 299 32 196617 sel 1;
> #P newex 122 299 32 196617 sel 1;
> #P newex 83 298 32 196617 sel 1;
> #P newex 45 299 32 196617 sel 1;
> #P newex 417 399 32 196617 sel 1;
> #P newex 454 399 32 196617 sel 1;
> #P newex 491 399 32 196617 sel 1;
> #P newex 528 399 32 196617 sel 1;
> #P newex 236 464 32 196617 sel 1;
> #P newex 234 484 29 196617 t 15;
> #P newex 528 418 29 196617 t 14;
> #P newex 491 418 29 196617 t 13;
> #P newex 457 418 29 196617 t 12;
> #P newex 423 418 29 196617 t 11;
> #P newex 197 320 21 196617 t 9;
> #P newex 160 320 21 196617 t 8;
> #P newex 122 322 21 196617 t 7;
> #P newex 83 321 21 196617 t 6;
> #P newex 45 322 21 196617 t 5;
> #P newex 218 548 47 196617 s 2menu;
> #P user led 546 356 17 17 0 150;
> #P comment 569 356 37 196617 2 3 4;
> #P newex 546 332 27 196617 &&;
> #P comment 460 355 34 196617 1 2 4;
> #P user led 494 355 17 17 0 150;
> #P comment 388 356 34 196617 1 3 4;
> #P user led 421 356 17 17 0 150;
> #P comment 339 356 34 196617 1 2 3;
> #P user led 324 356 17 17 0 150;
> #P user led 235 444 17 17 0 150;
> #P comment 250 446 43 196617 1 2 3 4;
> #P newex 235 425 27 196617 &&;
> #P newex 327 334 27 196617 &&;
> #P newex 509 143 76 196617 unpack 0 0 0 0;
> #P user radiogroup 509 61 18 76;
> #X size 4;
> #X offset 20;
> #X inactive 0;
> #X itemtype 1;
> #X flagmode 0;
> #X set 1 1 1 1;
> #X done;
> #P window setfont “Sans Serif” 14.;
> #P window linecount 0;
> #P comment 248 100 149 196622 right to left solution;
> #P window setfont “Sans Serif” 9.;
> #P window linecount 1;
> #P comment 853 318 100 196617 Hi everyone , Here’s my problem. I have a
> radiogroup with 4 check boxes. if I click on the first check box , I want 1
> if I click on the second check box , I want 2 and so on. Now , if the first
> & second boxes are checked , I want 5. and if the first & third boxes are
> checked then I want 6 , and if the first & fourth boxes are checked , then I
> want 7. etc. So I have fifteen possible combinations with these four check
> boxes , but I don’t achieve my goal. I tryed many solutions without success;
> #P connect 63 0 33 0;
> #P connect 33 0 18 0;
> #P connect 64 0 34 0;
> #P connect 34 0 19 0;
> #P connect 35 0 20 0;
> #P connect 40 0 36 0;
> #P connect 36 0 21 0;
> #P connect 40 1 37 0;
> #P connect 37 0 22 0;
> #P connect 27 0 17 0;
> #P connect 26 0 17 0;
> #P connect 25 0 17 0;
> #P connect 24 0 17 0;
> #P connect 23 0 17 0;
> #P connect 21 0 17 0;
> #P connect 22 0 17 0;
> #P connect 20 0 17 0;
> #P connect 19 0 17 0;
> #P connect 18 0 17 0;
> #P connect 8 0 68 0;
> #P connect 28 0 27 0;
> #P connect 68 0 5 0;
> #P connect 5 0 7 0;
> #P connect 7 0 28 0;
> #P connect 68 1 5 1;
> #P connect 10 0 68 1;
> #P connect 72 0 73 0;
> #P connect 4 0 8 0;
> #P connect 63 0 67 0;
> #P connect 67 0 4 0;
> #P connect 67 1 4 1;
> #P connect 64 0 67 1;
> #P connect 72 0 70 0;
> #P connect 70 0 71 0;
> #P connect 8 0 32 0;
> #P connect 64 0 66 0;
> #P connect 66 0 65 0;
> #P connect 65 0 10 0;
> #P connect 32 0 23 0;
> #P connect 39 0 63 0;
> #P connect 66 1 65 1;
> #P connect 62 0 66 1;
> #P connect 10 0 31 0;
> #P connect 31 0 24 0;
> #P connect 3 0 39 0;
> #P connect 3 1 39 1;
> #P connect 12 0 30 0;
> #P connect 30 0 25 0;
> #P connect 63 0 58 0;
> #P connect 58 0 57 0;
> #P connect 57 0 12 0;
> #P connect 39 1 64 0;
> #P connect 3 0 39 2;
> #P connect 2 0 3 0;
> #P connect 58 1 57 1;
> #P connect 3 2 39 3;
> #P connect 62 0 58 1;
> #P connect 3 0 39 4;
> #P connect 16 0 29 0;
> #P connect 29 0 26 0;
> #P connect 3 3 39 5;
> #P connect 54 0 56 0;
> #P connect 56 0 14 0;
> #P connect 14 0 16 0;
> #P connect 39 2 62 0;
> #P connect 56 1 14 1;
> #P connect 55 0 56 1;
> #P connect 3 1 40 0;
> #P connect 40 0 54 0;
> #P connect 3 2 40 1;
> #P connect 40 1 55 0;
> #P connect 3 1 40 2;
> #P connect 3 3 40 3;
> #P connect 41 0 51 0;
> #P connect 3 2 41 0;
> #P connect 3 3 41 1;
> #P connect 3 0 43 0;
> #P connect 3 1 45 0;
> #P connect 43 0 38 0;
> #P connect 45 0 38 1;
> #P connect 47 0 38 2;
> #P connect 3 2 47 0;
> #P connect 49 0 38 3;
> #P connect 3 3 49 0;
> #P pop;
> #P newobj 138 81 202 196626 p right to left solution;
> #P window setfont “Sans Serif” 9.;
> #P newex 35 172 47 196617 r 2menu;
> #P number 35 235 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P window setfont “Sans Serif” 18.;
> #P user ubumenu 35 197 208 196626 0 1 1 0;
> #X add off;
> #X add matrice 1;
> #X add matrice 2;
> #X add matrice 3;
> #X add matrice 4;
> #X add matrice 1+2;
> #X add matrice 1+3;
> #X add matrice 1+4;
> #X add matrice 2+3;
> #X add matrice 2+4;
> #X add matrice 3+4;
> #X add matrices 1+2+3;
> #X add matrices 1+2+4;
> #X add matrices 1+3+4;
> #X add matrices 2+3+4;
> #X add matrices 1+2+3+4;
> #X prefix_set 0 0
0;
> #P window setfont “Sans Serif” 9.;
> #P newex 81 235 209 196617 sel 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15;
> #P comment 103 563 31 196617 15;
> #P comment 103 540 31 196617 14;
> #P comment 103 520 31 196617 13;
> #P comment 103 500 31 196617 12;
> #P comment 103 480 26 196617 11;
> #P comment 103 460 22 196617 10;
> #P comment 103 440 22 196617 9;
> #P comment 103 420 22 196617 8;
> #P comment 103 400 22 196617 7;
> #P comment 103 380 22 196617 6;
> #P comment 103 360 22 196617 5;
> #P comment 103 340 22 196617 4;
> #P comment 103 320 22 196617 3;
> #P comment 103 300 22 196617 2;
> #P comment 103 282 22 196617 1;
> #P comment 43 564 52 196617 1+2+3+4;
> #P comment 45 541 40 196617 2+3+4;
> #P comment 45 521 40 196617 1+3+4;
> #P comment 45 501 40 196617 1+2+4;
> #P comment 45 481 40 196617 1+2+3;
> #P comment 45 461 26 196617 3+4;
> #P comment 45 441 26 196617 2+4;
> #P comment 45 421 26 196617 2+3;
> #P comment 45 401 26 196617 1+4;
> #P comment 45 381 26 196617 1+3;
> #P comment 45 361 26 196617 1+2;
> #P comment 45 341 14 196617 4;
> #P comment 45 321 14 196617 3;
> #P comment 45 301 14 196617 2;
> #P comment 45 283 14 196617 1;
> #P user led 366 376 17 17 0 150;
> #P user led 564 439 17 17 0 150;
> #P comment 582 439 37 196617 2 3 4;
> #P newex 565 416 27 196617 &&;
> #P user led 670 376 17 17 0 150;
> #P user led 600 376 17 17 0 150;
> #P user led 539 376 17 17 0 150;
> #P user led 639 301 17 17 0 150;
> #P comment 656 301 17 196617 4;
> #P user led 543 301 17 17 0 150;
> #P comment 560 301 17 196617 3;
> #P user led 447 301 17 17 0 150;
> #P comment 464 301 17 196617 2;
> #P user led 351 301 17 17 0 150;
> #P comment 368 301 17 196617 1;
> #P user led 286 376 17 17 0 150;
> #P user led 464 376 17 17 0 150;
> #P comment 447 439 34 196617 1 2 4;
> #P user led 481 439 17 17 0 150;
> #P newex 469 416 27 196617 &&;
> #P comment 368 439 34 196617 1 3 4;
> #P user led 401 439 17 17 0 150;
> #P comment 313 439 34 196617 1 2 3;
> #P user led 298 439 17 17 0 150;
> #P user led 342 496 17 17 0 150;
> #P comment 342 498 44 196617 1 2 3 4;
> #P newex 342 477 28 196617 &&;
> #P newex 384 416 27 196617 &&;
> #P newex 324 416 27 196617 &&;
> #P newex 599 353 27 196617 &&;
> #P comment 617 376 37 196617 2 et 4;
> #P comment 557 376 37 196617 2 et 3;
> #P newex 547 353 27 196617 &&;
> #P comment 433 376 37 196617 1 et 4;
> #P newex 428 353 27 196617 &&;
> #P comment 375 376 37 196617 1 et 3;
> #P newex 367 353 27 196617 &&;
> #P comment 688 376 40 196617 3 et 4;
> #P newex 661 353 27 196617 &&;
> #P comment 303 376 33 196617 1 et 2;
> #P newex 297 353 27 196617 &&;
> #P newex 438 261 76 196617 unpack 0 0 0 0;
> #P user radiogroup 438 176 18 76;
> #X size 4;
> #X offset 20;
> #X inactive 0;
> #X itemtype 1;
> #X flagmode 0;
> #X set 0 1 0 0;
> #X done;
> #P connect 76 0 74 0;
> #P connect 74 0 75 0;
> #P fasten 74 0 73 0 40 231 86 231;
> #P connect 2 0 27 0;
> #P connect 1 0 2 0;
> #P connect 14 0 19 0;
> #P connect 1 1 2 1;
> #P connect 2 0 14 0;
> #P connect 6 0 14 1;
> #P connect 14 0 16 0;
> #P connect 16 0 18 0;
> #P connect 1 0 29 0;
> #P connect 15 0 16 1;
> #P connect 6 0 42 0;
> #P connect 1 0 6 0;
> #P connect 1 2 6 1;
> #P connect 6 0 15 0;
> #P connect 8 0 15 1;
> #P connect 15 0 21 0;
> #P connect 1 0 8 0;
> #P connect 0 0 1 0;
> #P connect 1 3 8 1;
> #P connect 1 1 31 0;
> #P connect 8 0 26 0;
> #P connect 2 0 23 0;
> #P connect 23 0 24 0;
> #P connect 8 0 23 1;
> #P connect 10 0 36 0;
> #P connect 1 2 33 0;
> #P connect 1 1 10 0;
> #P connect 1 2 10 1;
> #P connect 39 0 41 0;
> #P connect 36 0 39 0;
> #P connect 37 0 39 1;
> #P connect 1 1 13 0;
> #P connect 13 0 37 0;
> #P connect 1 3 13 1;
> #P connect 1 3 35 0;
> #P connect 1 2 4 0;
> #P connect 4 0 38 0;
> #P connect 1 3 4 1;
> #P pop;
>

Cheers
Gary Lee Nelson
Oberlin College
http://www.timara.oberlin.edu/GaryLeeNelson

#117381
Nov 19, 2007 at 10:45pm

Doesn’t the radiogroup Flag mode more or less do what you want? It
treats each checkbox as a binary bit.

#P window setfont “Sans Serif” 9.;
#P number 105 157 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P user radiogroup 105 88 18 64;
#X size 4;
#X offset 16;
#X inactive 0;
#X itemtype 1;
#X flagmode 1;
#X set 0 0 0 0;
#X done;
#P connect 0 0 1 0;
#P window clipboard copycount 2;


Chris Muir | “There are many futures and only one status quo.
cbm@well.com | This is why conservatives mostly agree,
http://www.xfade.com | and radicals always argue.” – Brian Eno

#117382
Nov 20, 2007 at 2:20am

I just noticed the way you had the menu ordered. You will need
something to translate from binary to your menu layout. Here, I used
a coll:

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P comment 57 163 14 196617 4;
#P comment 57 142 14 196617 3;
#P comment 57 121 14 196617 2;
#N coll Xlate4menu 1;
#T flags 1 0;
#T 0 0;
#T 1 1;
#T 2 2;
#T 3 5;
#T 4 3;
#T 5 6;
#T 6 8;
#T 7 11;
#T 8 4;
#T 9 7;
#T 10 9;
#T 11 12;
#T 12 10;
#T 13 13;
#T 14 14;
#T 15 15;
#P newobj 42 181 90 196617 coll Xlate4menu 1;
#P window setfont “Sans Serif” 18.;
#P user ubumenu 42 204 208 196626 0 1 1 0;
#X add off;
#X add matrice 1;
#X add matrice 2;
#X add matrice 3;
#X add matrice 4;
#X add matrice 1+2;
#X add matrice 1+3;
#X add matrice 1+4;
#X add matrice 2+3;
#X add matrice 2+4;
#X add matrice 3+4;
#X add matrices 1+2+3;
#X add matrices 1+2+4;
#X add matrices 1+3+4;
#X add matrices 2+3+4;
#X add matrices 1+2+3+4;
#X prefix_set 0 0 0;
#P user radiogroup 42 99 18 76;
#X size 4;
#X offset 20;
#X inactive 0;
#X itemtype 1;
#X flagmode 1;
#X set 0 0 0 0;
#X done;
#P window setfont “Sans Serif” 9.;
#P window linecount 16;
#P hidden comment 263 60 43 196617 0 , 0 ; 1 , 1 ; 2 , 2 ; 3 ,
5 ; 4 , 3 ; 5 , 6 ; 6 , 8 ; 7 , 11 ; 8 , 4 ; 9 , 7 ; 10
, 9 ; 11 , 12 ; 12 , 10 ; 13 , 13 ; 14 , 14 ; 15 , 15 ;;
#P window linecount 1;
#P hidden comment 258 46 58 196617 Xlate table;
#P comment 57 100 14 196617 1;
#P connect 5 0 4 0;
#P connect 3 0 5 0;
#P window clipboard copycount 9;


Chris Muir | “There are many futures and only one status quo.
cbm@well.com | This is why conservatives mostly agree,
http://www.xfade.com | and radicals always argue.” – Brian Eno

#117383
Nov 20, 2007 at 2:12pm

Ah, that’s too easy.

(Must be getting old if I’m forgetting radiogroup’s flag mode).

I had wanted to demonstrate the arithmetic behind binary flags in my patch, because that’s something that many beginners view as some sort of black magic when it is really very simple.

Demonstrating coll, as you did, Chris, is also valuable. Coll is a flexible general-purpose data storage object. However, if indices and values are integers (and particularly if indices are contiguous), I tend to prefer table:

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#N vtable 16 330 471 540 638 979720 16 anotherTranslator;
#T set 0 0 1 2 5 3 6 8 11 4 7 9 12 10 13 14 15;
#P newobj 42 181 131 196617 table anotherTranslator 1;
#P comment 57 163 14 196617 4;
#P comment 57 142 14 196617 3;
#P comment 57 121 14 196617 2;
#P window setfont “Sans Serif” 18.;
#P user ubumenu 42 204 208 196626 0 1 1 0;
#X add off;
#X add matrice 1;
#X add matrice 2;
#X add matrice 3;
#X add matrice 4;
#X add matrice 1+2;
#X add matrice 1+3;
#X add matrice 1+4;
#X add matrice 2+3;
#X add matrice 2+4;
#X add matrice 3+4;
#X add matrices 1+2+3;
#X add matrices 1+2+4;
#X add matrices 1+3+4;
#X add matrices 2+3+4;
#X add matrices 1+2+3+4;
#X prefix_set 0 0 0;
#P user radiogroup 42 99 18 76;
#X size 4;
#X offset 20;
#X inactive 0;
#X itemtype 1;
#X flagmode 1;
#X set 0 0 0 0;
#X done;
#P window setfont “Sans Serif” 9.;
#P comment 57 100 14 196617 1;
#P connect 6 0 2 0;
#P connect 1 0 6 0;
#P window clipboard copycount 7;

This seems to be the useful-tricks-of-the-week thread.

#117384

You must be logged in to reply to this topic.