using sprintf to dynamically size textbutton

underworld9202's icon

Hello all

I'm sure I'm just being daft but I can't get sprintf to set the size of my textbutton.

I've written [sprintf script newobject textbutton @text go @varname go_button @textcolor 0.2 0.6 0.9 1. @fontface bold @fontsize 32 @patching_position %i %i]

and have tried adding @size, size, @patching_size, patching_size (followed by two integers) to set the size but nothing seems to work.

Am I missing something blindingly obvious?

1679.sprintftest.maxpat
Max Patch
Luke Hall's icon

Change "@patching_position 1 2" to "@patching_rect 1 2 3 4" and it will work.

Emmanuel Jourdan's icon
Max Patch
Copy patch and select New From Clipboard in Max.

You might also want to avoid using sprintf which really made for string concatenation.

underworld9202's icon

Thank you Emmanuel for a much neater solution!