Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 03-31-2021, 04:28 AM   #1
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 10,948
Karma: 74999999
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Template: Displaying only non-zero values

Is this the best way to do it for a composite column?

Code:
program:
	x = $$#integer;
	if 
		x !=# 0 
	then
		x
	fi

Last edited by ownedbycats; 03-31-2021 at 04:35 AM.
ownedbycats is offline   Reply With Quote
Old 03-31-2021, 04:56 AM   #2
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 10,948
Karma: 74999999
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
I noticed this displays 'none' for an undefined.
ownedbycats is offline   Reply With Quote
Advert
Old 03-31-2021, 05:02 AM   #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,440
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Is this the best way to do it for a composite column?

Code:
program:
	x = $$#integer;
	if 
		x !=# 0 
	then
		x
	fi
That works fine, but I would use
Code:
cmp(t = $#myint, 0, t, '', t)

Last edited by chaley; 03-31-2021 at 06:19 AM. Reason: Fix the template
chaley is offline   Reply With Quote
Old 03-31-2021, 06:17 AM   #4
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,440
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
I noticed this displays 'none' for an undefined.
It doesn't for me. The 'none' value gets turned into zero for arithmetic comparisons so you should see only numbers in the 'then' clause.

But after the 'if' the variable 'x' will contain 'none'. If you don't want that then use
Code:
x = raw_field(#myint', 0)
chaley is offline   Reply With Quote
Old 03-31-2021, 09:58 AM   #5
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 10,948
Karma: 74999999
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Quote:
Originally Posted by chaley View Post
That works fine, but I would use
Code:
cmp(t = $#myint, 0, t, '', t)
That's a lot simpler. thank you
ownedbycats is offline   Reply With Quote
Advert
Old 04-15-2021, 11:54 PM   #6
MarjaE
Guru
MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.
 
Posts: 937
Karma: 53902736
Join Date: Jun 2015
Device: multiple
Hi, I have a #ratio column:

program: format_number(divide(booksize(),add(raw_field("#pa ges"),1)),"{0:,.0f}")

How could I amend that to avoid showing values of 0 or none?
MarjaE is offline   Reply With Quote
Old 04-16-2021, 04:09 AM   #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,440
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by MarjaE View Post
Hi, I have a #ratio column:

program: format_number(divide(booksize(),add(raw_field("#pa ges"),1)),"{0:,.0f}")

How could I amend that to avoid showing values of 0 or none?
I don't know what version of calibre you are running so I am using the older syntax.
Code:
program: 
	s = divide(booksize(),add(raw_field("#pages"),1));
	cmp(s, 0, '', '', format_number(s,"{0:,.0f}"))
chaley is offline   Reply With Quote
Old 04-23-2021, 04:37 PM   #8
MarjaE
Guru
MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.MarjaE ought to be getting tired of karma fortunes by now.
 
Posts: 937
Karma: 53902736
Join Date: Jun 2015
Device: multiple
Thanks. I got mixed up, the tricky one is #pages which uses the Count Pages plugin.
MarjaE is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using built-in template functions in a custom template function ilovejedd Library Management 4 01-28-2018 12:20 PM
Use column values to determine author link template? eosrose Calibre 3 08-24-2013 12:34 AM
Display template values not saved to metadata.calibre meme Devices 2 02-13-2011 01:27 AM
displaying multiple values in the same column beneath each other Firedancer885 Calibre 2 11-27-2010 03:13 PM


All times are GMT -4. The time now is 02:12 PM.


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