View Single Post
Old 01-09-2023, 04:03 PM   #7
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by jwahome2002 View Post
What programming language is this? I know VBA and SQL. I'd like to get more familiar with this.
It is a language I made up for fun, basing it on ideas from functional programming and several languages of my youth: Algol 68, lisp, and Pascal. Nobody liked the functional stuff, which is why I added Pascal/Algol statements a while back. You can see the language grammar and examples in the documenation I linked to.

Note also that you can write templates in pure Python 3, should that be of interest. The documentation tells you how to do it. You would need to look at the calibre database api.
Quote:
One last question if I may - the book number is not sorting correctly. I have a list that the system sorts 1, 10, 11, 2... I cannot figure out what the format is to add preceding zeros.

Much appreciated!!
Use the format_number() function. Here is an example formatting an integer as 3 digits with leading zeros. It makes a list of them, sorts the list, then displays it. Try it in the Template Tester dialog.
Code:
program:
	output = '';
	for i in range(40, 0, -5):
		output = output & format_number(i, '03d') & ','
	rof;
	list_sort(output, 0, ',')
chaley is offline   Reply With Quote