numbering 01 to 09
apologies for such a silly question, but I have been trying to get a numbering series from 01 to 09, and all I am getting is 1, 2 … 9 (without the 0). I am using these numbers as part of a file naming process. The 0 is important since, as you might know, windows presents files with a 0 (01, 02 etc) before those without it, within the same folder, let’s say. This is important in my application…
I’ve tried sending the incoming numbers (1 to 9) to sprintf 0%ld, expecting to get 01 to 09 at the other end, but it’s not working.. I’ve also tried other methods…How can this be done?
Try [sprintf symout %.2d]. It is documented in the "more examples" subpath in the [sprintf] help file.
forgot to say i am still using 4.6.3, perhaps you refer to the help file on max 5? I cannot find a ‘more examples’ subpatch in the sprintf help file…
Ah, well it is there in the max 5 helpfile, it must be a new addition. If I remember correctly the functionality is still there in 4.6 even if it isn’t mentioned in the help file.
An example with a clock:
----------begin_max5_patcher---------- 428.3ocwU1saBBCEG+Z3onoI6NlgV9PF2smiEyRUpXWfVC8XlaFe2GsfeMUF Ncta5IbNs87+7qmVV45fGqVx0XTJ5EjiyJWGGqKiCm1ucvkrkSJXZ6zvkbsl kywdMw.9Rv52OIMHLkNbS.4hR0BnfC1kQZ8NUIAs3StwWP7.+V2MyD9XNuQJ XLZTan4LXxLgL+0J9DnIZRP8BQz.hwPRhLlv5Ma6ZDYVIoF+1iD7dYVxJsI. +bkfUrmRExMBkZ7s100L30SjH4uWmpiHhddkPBSQZNfdX.MKc6P+YzSWGhH9 VDE1PpgmFQzKDQA+BDAp77Bd208QUXM85rHiSrkE01.P1NdpZL3jUB41cXWx gJEJx2+lb1NlIy6Soa558Pw9cc7FdGtAbtGE.QI+uuYuEFMFZbW8AQ+eOGjw fyvhfKiEEBMf81Y640jDqIrydk3KDO6eAxte0hR98+mXkjw+gLSqVTMYSM0d GEsSUYbMHjLPnj6MmvClyLQVF2FdCrJEYyU0.oUBnQm77quJJrGJJ5tpnndn n36phLYi7CJhdWUDsGLhbEJp9i0teMPAcjO -----------end_max5_patcher-----------
|dan m wrote on Wed, 25 March 2009 01:48|
|forgot to say i am still using 4.6.3, perhaps you refer to the help file on max 5? I cannot find a ‘more examples’ subpatch in the sprintf help file…|
The More Examples subpatch may be new in Max 5, but the sprintf functionality isn’t.
It’s unfortunate that the reference documents assume familiarity with sprintf syntax. Although this syntax is used in literally dozens of programming languages, a lot of people come to Max with zero programming background. However, if you poke around a bit, you will probably find plenty of sample patches using the technique.
I’ve also just written a list of sources for sprintf syntax on the ‘check for decimal places’ thread.
ok, I have installed the demo version of max 5, just to check the help file. I have also opened the clock patch. Dont know if I am doing something wrong, but while it works in max 5, it does not work in max 4.
Furthermore, the help file includes ‘toto’ [sprintf TOTO%.2d]. If I get rid of the word ‘toto’ in max 5, it does not work (it outputs 1, 2 etc).
The clock works fine in max 5, but the same expression in max 4, something like [sprintf set %.2d], does not output the 0 in front of any number…If I add ‘toto’, it works… So it seems the string must begin with something other than 0?
Am I doing something wrong? Has somebody tried this on max 4.x?
I was hoping to get this done without getting into spritnf syntax. It’s just a zero por dios!
Max automatically removes leading zeroes so you have to use the "symout" argument like thus [sprintf symout %.2d] to make it output a symbol which you can view in a message box rather than a number box.
[110.concat- 0] will also do it.
And maybe something to try with [combine] (Max5 only):
----------begin_max5_patcher---------- 363.3ocuTFsaCBBEF9Z7ofbt1s.N6pY2smi0lETYsrnPiPy5VSe2Gf3Z6Vai t13MX3mCG+4yebaDBxUa3Z.+D9ELBsMBg7RNATXNBpYaJpXZeYfj+gJ+cHtc ICeiwKav4XQmpbcsZsoha7aIIn9lRZzhu3NMZx8jfbaklOWwasAjyjKfXLHj 1VOOT0JloXoPt30FdgosvjThsI3jGb8BaGmXmXk9YOhRu0r18tL3.SHY092E 7bifUcfoExNOScZ6hhbCw8jL0bslsf+GzLCHoyfSyF5.YykABI0Sh1GS7zgl cZfLcf.I4e.DaCx4M2lPgKLDGxF8ITPH6Yv4BEoiPn3LWWJT04BIGStUWZbv oWf4Qe3XZxk.C8JBG99AU1C2u9sh2SN8iokVston6TDtph26pRt1HjLiPIOn F5Q0rTTVx8K2gmZQ4JkMxDr.d9I+xMDGQ6giniliR6AixFUFQ6gildELxNYW z2.q7cnV -----------end_max5_patcher-----------
symout does the job : [sprintf symout %.2d] in max 4.6.3
There was an older version of max in my pc which didnt like symout. Now it’s fine…