Clock CHOP : How to get 2 numbers instead of 1? [Solved]

Just a simple question about Clock CHOP:

Secondes, minutes, also hours could have only 1 number : 1,2,3,4,5,6,7,8,9.
I would like to forced display numbers to two numbers : 01,02 ,03 ,04 ,05 ,06 , 07 ,08 , 09

How could I easily do that with an other node or python’ script?

You can use .format()

For example, a say you wanted to do this with seconds from a clock CHOP, the following would always evaluate with leading zeros:

'{0:02d}'.format( int( op( 'clock1' )[ 'sec' ] ) )

zfill() is what I use:

tutorialspoint.com/python/string_zfill.htm

Thank you to both of you ^^
Problem solved :wink:

Matthew -

I don’t understand how this code is used. I want to format the MIN channel from a clockCHOP so I can build in a time-of-day (H:MM) display on my schedule output. I have sent the data to a textTOP and have tried putting this code (modified for [‘min’]) in the CHOP Value %-Replace expression but it does not seem to work.

The help file for the textTOP is not very helpful!

thanks again for your help

Andy

Hey Andy,

Clocks are hard in touch. The text TOP is faster than it used to be, but rendering text in general can be slow. Given that here are a few examples to help you decide the best path forward.

CHOP replace method - this uses the native CHOP value replace approach. Here the formatting of the text field describes how the values from a CHOP will be used in formatting time. You can see more about how that works on the text TOP page:
derivative.ca/wiki099/index. … e=Text_TOP

Pythonic method - this uses format() and python to do the same thing as above. You can read more about how format() works here:
docs.python.org/3.5/library/std … str.format

Finally, the most efficient way to do this would be to fill a cache with numbers that you then look up. This avoids the expense of actually doing the rendering, and instead just pulls images from memory. This is the most computationally efficient, but requires that you set aside memory for the text.

Hope this helps.
base_clocks.tox (1.25 KB)