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 10-24-2014, 04:30 PM   #16
treadlightly
Wizard
treadlightly ought to be getting tired of karma fortunes by now.treadlightly ought to be getting tired of karma fortunes by now.treadlightly ought to be getting tired of karma fortunes by now.treadlightly ought to be getting tired of karma fortunes by now.treadlightly ought to be getting tired of karma fortunes by now.treadlightly ought to be getting tired of karma fortunes by now.treadlightly ought to be getting tired of karma fortunes by now.treadlightly ought to be getting tired of karma fortunes by now.treadlightly ought to be getting tired of karma fortunes by now.treadlightly ought to be getting tired of karma fortunes by now.treadlightly ought to be getting tired of karma fortunes by now.
 
treadlightly's Avatar
 
Posts: 1,370
Karma: 6957792
Join Date: Nov 2010
Location: Ottawa, ON
Device: Kobo H2O
Quote:
Originally Posted by chaley View Post
Not much of one unless someone makes a plugin to do it. The problem is that functions like that require access to all books, not just the current one. The template system is limited to one book at a time.

It is of course possible to do this sort of thing in plugins and in python "calibre helper scripts" (calibre-debug -e script.py), but neither of these are useful for someone who isn't already a python programmer.
Ok, thanks. I wish I was talented enough to write a plugin, but alas.
treadlightly is offline   Reply With Quote
Old 10-24-2014, 06:09 PM   #17
Nyssa
Series Addict
Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.
 
Nyssa's Avatar
 
Posts: 6,180
Karma: 167189477
Join Date: Dec 2010
Location: Florida, USA
Device: Kindle Paperwhite (2nd Gen)
Chaley - Going off of a similar issue as the previous "penny problem" (thanks again ), I have Calibre set up to "highlight" all of my freebies with text coloring "If the price column is equal to value: 0.00".

Unfortunately, calibre can not seem to determine the difference between "0.00" and "undefined", nor can I point out that distinction in the rules, so anything that has not yet been priced, has also been "highlighted".

Any suggestions?

Please & Thank you.

Last edited by Nyssa; 10-25-2014 at 10:27 AM.
Nyssa is offline   Reply With Quote
Old 10-25-2014, 06:28 AM   #18
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,453
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Nyssa View Post
Chaley - Going off of a similar issue as the previous "penny problem" (thanks again ), I have Calibre set up to "highlight" all of my freebies with text coloring "If the price column is equal to value: 0.00".

Unfortunately, calibre can not seem to determine the difference between "0.00" and "undefined", nor can I point out that distinction in the rules, so anything that has not yet been priced is also been "highlighted".

Any suggestions?

Please & Thank you.
You are correct. Empty is considered to be zero.

You can get around this by using an advanced rule that can check if the column is empty before comparing it to zero. Here is an example:
Code:
program:
	test(field('#myfloat'), cmp(raw_field('#myfloat'), 0, '', '#00aa00', ''), '')
The "test" function first checks to see if the field contains any text. If it does then it compares the field with zero, and if equal returns (in this example) the color green. Otherwise it returns nothing.

You must use raw_field() in the comparison because of the formatting. The word "Price" is not a number. You must use field() in the test so you can tell the difference between empty and "Price: 0.00" (or whatever it is).
chaley is offline   Reply With Quote
Old 10-25-2014, 11:24 AM   #19
Nyssa
Series Addict
Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.
 
Nyssa's Avatar
 
Posts: 6,180
Karma: 167189477
Join Date: Dec 2010
Location: Florida, USA
Device: Kindle Paperwhite (2nd Gen)
Quote:
Originally Posted by chaley View Post
You are correct. Empty is considered to be zero.

You can get around this by using an advanced rule that can check if the column is empty before comparing it to zero. Here is an example:
Code:
program:
	test(field('#myfloat'), cmp(raw_field('#myfloat'), 0, '', '#00aa00', ''), '')
The "test" function first checks to see if the field contains any text. If it does then it compares the field with zero, and if equal returns (in this example) the color green. Otherwise it returns nothing.

You must use raw_field() in the comparison because of the formatting. The word "Price" is not a number. You must use field() in the test so you can tell the difference between empty and "Price: 0.00" (or whatever it is).
I'm apparently doing something wrong.

Code:
 test(field('#price'), cmp(raw_field('#price:0.00'), 0, '', '#2aa29e', ''), '')

Last edited by Nyssa; 10-25-2014 at 11:55 AM.
Nyssa is offline   Reply With Quote
Old 10-25-2014, 11:40 AM   #20
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,453
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Nyssa View Post
I'm apparently doing something wrong.

Code:
 test(field('#price'), cmp(raw_field('#price:0.00'), 0, '', '#2aa29e', ''), '')
I see two mistakes.

1) The "program:" in my example is important. That tells the template processor that what follows is code and not text.

2) the raw_field() should contain '#price' without the ':0.00'.

This should work
Code:
program: test(field('#price'), cmp(raw_field('#price'), 0, '', '#2aa29e', ''), '')
chaley is offline   Reply With Quote
Old 10-25-2014, 11:54 AM   #21
Nyssa
Series Addict
Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.
 
Nyssa's Avatar
 
Posts: 6,180
Karma: 167189477
Join Date: Dec 2010
Location: Florida, USA
Device: Kindle Paperwhite (2nd Gen)
Quote:
Originally Posted by chaley View Post
I see two mistakes.

1) The "program:" in my example is important. That tells the template processor that what follows is code and not text.

2) the raw_field() should contain '#price' without the ':0.00'.

This should work
Code:
program: test(field('#price'), cmp(raw_field('#price'), 0, '', '#2aa29e', ''), '')
Oh.. I had price by itself the first time, but then added the "0.00" when that didn't work.

Unfortunately, even after adding program, (and removing the zeros) the code did not work.
Nyssa is offline   Reply With Quote
Old 10-25-2014, 12:15 PM   #22
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,453
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Nyssa View Post
Oh.. I had price by itself the first time, but then added the "0.00" when that didn't work.

Unfortunately, even after adding program, (and removing the zeros) the code did not work.
What does it do?

Note that there can be no spaces before the word program.
chaley is offline   Reply With Quote
Old 10-25-2014, 12:25 PM   #23
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,453
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
This is what you should see in the advanced rule editor, except for #price instead of #myfloat.
Attached Thumbnails
Click image for larger version

Name:	Clipboard01.jpg
Views:	169
Size:	39.4 KB
ID:	130153  
chaley is offline   Reply With Quote
Old 10-25-2014, 01:06 PM   #24
Nyssa
Series Addict
Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.
 
Nyssa's Avatar
 
Posts: 6,180
Karma: 167189477
Join Date: Dec 2010
Location: Florida, USA
Device: Kindle Paperwhite (2nd Gen)
Quote:
Originally Posted by chaley View Post
What does it do?

Note that there can be no spaces before the word program.
Quote:
Originally Posted by chaley View Post
This is what you should see in the advanced rule editor, except for #price instead of #myfloat.
I made sure there wasn't a space.

Its still not seeing a difference between "0.00" and "undefined".
Nyssa is offline   Reply With Quote
Old 10-25-2014, 01:25 PM   #25
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,453
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Nyssa View Post
I made sure there wasn't a space.

Its still not seeing a difference between "0.00" and "undefined".
Did you delete your previous rule that didn't work?
chaley is offline   Reply With Quote
Old 10-25-2014, 03:11 PM   #26
Nyssa
Series Addict
Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.
 
Nyssa's Avatar
 
Posts: 6,180
Karma: 167189477
Join Date: Dec 2010
Location: Florida, USA
Device: Kindle Paperwhite (2nd Gen)
Quote:
Originally Posted by chaley View Post
Did you delete your previous rule that didn't work?
Yes, and added a new one. I also restarted Calibre, just in case.
Nyssa is offline   Reply With Quote
Old 10-25-2014, 04:12 PM   #27
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,453
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
I am running out of ideas because it works fine for me.

The following 4 attachments show what I have done.

First, I created a column #price so we aren't using different columns.
Click image for larger version

Name:	Clipboard01.png
Views:	253
Size:	28.8 KB
ID:	130160

Next I entered a rule:
Click image for larger version

Name:	Clipboard03.png
Views:	294
Size:	33.5 KB
ID:	130162

Here is that rule in the list:
Click image for larger version

Name:	Clipboard02.png
Views:	270
Size:	50.9 KB
ID:	130161

And here is the result:
Click image for larger version

Name:	Clipboard04.png
Views:	297
Size:	6.4 KB
ID:	130163

As you can see, the line with price 0.00 is green and the lines with no price are not.

Idea: some other rule is being applied to the lines so that the "price" rule is being ignored. Try moving the price rule to the top.
chaley is offline   Reply With Quote
Old 10-25-2014, 05:04 PM   #28
Nyssa
Series Addict
Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.
 
Nyssa's Avatar
 
Posts: 6,180
Karma: 167189477
Join Date: Dec 2010
Location: Florida, USA
Device: Kindle Paperwhite (2nd Gen)
Quote:
Originally Posted by chaley View Post
I am running out of ideas because it works fine for me.

The following 4 attachments show what I have done.

First, I created a column #price so we aren't using different columns.
Attachment 130160

Next I entered a rule:
Attachment 130162

Here is that rule in the list:
Attachment 130161

And here is the result:
Attachment 130163

As you can see, the line with price 0.00 is green and the lines with no price are not.

Idea: some other rule is being applied to the lines so that the "price" rule is being ignored. Try moving the price rule to the top.

I forgot to remove the original price related rule. I was so busy making sure I had the code written correctly I forgot about the other one.
So I had both the standard "If the price column is equal to value: 0.00", rule and the code you gave me. When you had asked me if i had removed the code that didn't work, I meant the one that I had copied incorrectly.
Scrolling the code to the top made me realize that the other one was there, even though I was looking at it the whole time.

Last edited by Nyssa; 10-25-2014 at 05:11 PM.
Nyssa is offline   Reply With Quote
Old 10-25-2014, 05:22 PM   #29
Nyssa
Series Addict
Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.Nyssa ought to be getting tired of karma fortunes by now.
 
Nyssa's Avatar
 
Posts: 6,180
Karma: 167189477
Join Date: Dec 2010
Location: Florida, USA
Device: Kindle Paperwhite (2nd Gen)
It all works!

Thank you Chaley!!!
Nyssa is offline   Reply With Quote
Old 07-13-2017, 08:52 PM   #30
Inukami
Zealot
Inukami began at the beginning.
 
Inukami's Avatar
 
Posts: 145
Karma: 12
Join Date: Jun 2017
Location: Australia
Device: Mac Pro 2013 & Mini 2018, iPad Mini 4, iPhone 11, iBooks, K4Mac/PC
@chaley, thanks for this information. It looks very useful and I think I will use the colouring for free books.

I'm also assuming you could get Calibre to also do the following with composite columns? If price is value or 0.00, have another column say either BOUGHT or FREE using logic...

On the other hand, I do have two currencies (Australian dollar & Japanese Yen). Would it be possible to choose which currency to choose from in one column, or would you need to make another column?

If you had to have another column #price2, could you set that to be active if the #price1 is blank?
  • Australian Dollars $5.00
  • Japanese Yen ¥650
  • Free Book $0.00

Inukami
Inukami is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Price Custom Column Formatting Help PaulineDesigns Library Management 13 07-22-2022 09:23 PM
Custom column returns value based on value of another custom column? calvin-c Calibre 3 09-14-2013 02:24 PM
Custom yes/no column built from long text column Philantrop Library Management 7 03-23-2013 07:44 PM
how to move value(s) of tag column to a custom made column zoorakhan Library Management 0 12-08-2012 03:53 AM
Can custom book data be displayed in a custom column? kiwidude Development 9 03-02-2011 05:35 AM


All times are GMT -4. The time now is 09:32 AM.


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