Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 04-17-2023, 07:49 AM   #1
hlhp
Member
hlhp began at the beginning.
 
Posts: 17
Karma: 10
Join Date: Mar 2019
Device: none
template function, how to combine float and string?

how can i combine the following to a string? can not find reference in doc, or i missing it.

Code:
program: floor(field('#floatx') / 333) + "books"
hlhp is offline   Reply With Quote
Old 04-17-2023, 11:10 AM   #2
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 31,047
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
a WAG (not a python coder)

Code:
format_number(v, template)
theducks is offline   Reply With Quote
Advert
Old 04-17-2023, 12:06 PM   #3
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,444
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by hlhp View Post
how can i combine the following to a string? can not find reference in doc, or i missing it.

Code:
program: floor(field('#floatx') / 333) + "books"
Assuming you want '+' to be string concatenation:
  • In the manual under General Program Mode
    Quote:
    String concatenation (&). The & operator returns a string formed by concatenating the left-hand and right-hand expressions. Example: 'aaa' & 'bbb' returns 'aaabbb'. The operator is associative and evaluates left to right.
  • In the manual under "Additional Functions Available":
    Quote:
    strcat(a [, b]*) – can take any number of arguments. Returns a string formed by concatenating all the arguments.
  • In the String manipulation section of the Function reference manual:
    strcat(a, b):
    Quote:
    class calibre.utils.formatter_functions.BuiltinStrcat[source]
    strcat(a [, b]*) – can take any number of arguments. Returns the string formed by concatenating all the arguments
chaley is offline   Reply With Quote
Old 04-17-2023, 02:04 PM   #4
hlhp
Member
hlhp began at the beginning.
 
Posts: 17
Karma: 10
Join Date: Mar 2019
Device: none
thank you theducks & chaley

I cannot believe I was looking at the wrong documentation. I replaced + with & and it works now.

Code:
program: floor(field("#floatx") / 333) & "a"
hlhp is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Template: Extracting a number from a string ownedbycats Library Management 8 06-25-2021 03:07 PM
How to access the url string in preprocess_html function? Ramana Recipes 2 12-10-2018 09:15 AM
Using built-in template functions in a custom template function ilovejedd Library Management 4 01-28-2018 12:20 PM
how to use re() function in Template Program Mode? msciwoj Library Management 3 07-07-2016 03:55 PM
The operator >> is undefined for the argument type(s) float, float twobob Kindle Developer's Corner 10 09-05-2012 12:50 PM


All times are GMT -4. The time now is 06:08 AM.


MobileRead.com is a privately owned, operated and funded community.