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 06-01-2020, 08:10 PM   #1
dunhill
Guru
dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.
 
dunhill's Avatar
 
Posts: 723
Karma: 228142
Join Date: Sep 2017
Location: Argentina
Device: moon+ reader, kindle paperwhite
Help with a template

I have a custom column with decimal numbers for the book grade.
I would like to make a column that depends on it to tell me if all the data in the book is complete, if the decimal column has the column heading "V. Decimal" and the query name # gr1.
What should the template be like?
I tried with program: test (select (field ('V. Decimal'), '<> "0"'), 'Yes', '')
Attached Thumbnails
Click image for larger version

Name:	1.PNG
Views:	141
Size:	79.9 KB
ID:	179639  
dunhill is offline   Reply With Quote
Old 06-02-2020, 05:38 AM   #2
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
I'm not sure what you are doing. But, I can see some errors.

Firstly, you don't refer to a column by the column heading. You need the lookup name. For a custom column, this will always start with a "#".

Then, "select" only works on identifier type columns. That means the value you are checking needs to have a ":" in it. Unless you are formatting the decimal with a colon instead of a dot, which I don't know how to do Or is the column a string that just happens to have a number?

And the second parameter of "select" is the id name. So, basically what is to the left of the colon.

If the column is actually a number, then the following might work (with your column's lookup name):

Code:
program:
raw_field(list_item(field('#mm_progress'),1,'.'),0,'','Yes','')
Which I really don't like. Because I am treating the number as a list using a dot as the separator, taking the second element and then comparing it to zero. It seems to work, but I don't like it.
davidfor is offline   Reply With Quote
Advert
Old 06-02-2020, 06:50 AM   #3
dunhill
Guru
dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.
 
dunhill's Avatar
 
Posts: 723
Karma: 228142
Join Date: Sep 2017
Location: Argentina
Device: moon+ reader, kindle paperwhite
Hi Davidfor
The column has a decimal number separated by ","
I have made replacements to his formula with my names and he doesn't seem to like it.
program:
raw_field (list_item (field ('# gr1'), 1, ','), 0, '', 'Yes', '')
Attached Thumbnails
Click image for larger version

Name:	1.png
Views:	122
Size:	34.9 KB
ID:	179646   Click image for larger version

Name:	2.png
Views:	122
Size:	45.8 KB
ID:	179647  
dunhill is offline   Reply With Quote
Old 06-02-2020, 07:53 AM   #4
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by dunhill View Post
Hi Davidfor
The column has a decimal number separated by ","
I have made replacements to his formula with my names and he doesn't seem to like it.
program:
raw_field (list_item (field ('# gr1'), 1, ','), 0, '', 'Yes', '')
I assume the comma is a locale thing. But, there shouldn't be a space after the "#".

If that isn't it, is there an error message?
davidfor is offline   Reply With Quote
Old 06-03-2020, 06:44 AM   #5
dunhill
Guru
dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.
 
dunhill's Avatar
 
Posts: 723
Karma: 228142
Join Date: Sep 2017
Location: Argentina
Device: moon+ reader, kindle paperwhite
Quote:
Originally Posted by davidfor View Post
I assume the comma is a locale thing. But, there shouldn't be a space after the "#".

If that isn't it, is there an error message?
Hello Davidfor The space appeared in the message when writing the code, in calibre it is not.
I leave screenshot with the error it gives.
Thank you !!
Attached Thumbnails
Click image for larger version

Name:	1.png
Views:	117
Size:	76.5 KB
ID:	179668   Click image for larger version

Name:	2.png
Views:	103
Size:	14.4 KB
ID:	179669  

Last edited by dunhill; 06-03-2020 at 06:50 AM.
dunhill is offline   Reply With Quote
Advert
Old 06-03-2020, 08:33 AM   #6
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Sorry, that was my mistake. What posted before was wrong. The first function should be "cmp", not "raw_field". I have no idea how I did that.

It should have been:

Code:
program:
cmp(list_item(field('#gr1'),1,','),0,'','Yes','')
The alternative is:
Code:
program:
cmp(list_item(raw_field('#gr1'),1,','),0,'','Yes','')
The possible advantage of that is that the value of #gr1 doesn't go through any formatting specified for the column. Though I don't know if the decimal point will be locale specific, so it could be a comma or a dot.
davidfor is offline   Reply With Quote
Old 06-03-2020, 01:12 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: 11,741
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by davidfor View Post
The possible advantage of that is that the value of #gr1 doesn't go through any formatting specified for the column. Though I don't know if the decimal point will be locale specific, so it could be a comma or a dot.
If the numbers come formatted with commas instead of dots then you might want to use raw_list instead of raw_field. That way you can choose an alternate separator, for example a colon.
chaley is offline   Reply With Quote
Old 06-03-2020, 10:11 PM   #8
dunhill
Guru
dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.
 
dunhill's Avatar
 
Posts: 723
Karma: 228142
Join Date: Sep 2017
Location: Argentina
Device: moon+ reader, kindle paperwhite
Quote:
Originally Posted by davidfor View Post
Sorry, that was my mistake. What posted before was wrong. The first function should be "cmp", not "raw_field". I have no idea how I did that.

It should have been:

Code:
program:
cmp(list_item(field('#gr1'),1,','),0,'','Yes','')
The alternative is:
Code:
program:
cmp(list_item(raw_field('#gr1'),1,','),0,'','Yes','')
The possible advantage of that is that the value of #gr1 doesn't go through any formatting specified for the column. Though I don't know if the decimal point will be locale specific, so it could be a comma or a dot.

Davidfor!
We are close the two codes work half, let's say
I don't know why because the "V. Decimal" column has no format or code. I leave catches.
If the column has a value it is ok to put yes.
And it is expected that if it is empty it will put No but yes.
I don't want to be annoying, if you can't. I forget about those settings. Thank you very much for your time and for the prompt responses.
Attached Thumbnails
Click image for larger version

Name:	1.png
Views:	127
Size:	58.6 KB
ID:	179702   Click image for larger version

Name:	2.png
Views:	104
Size:	70.1 KB
ID:	179703   Click image for larger version

Name:	3.png
Views:	103
Size:	18.9 KB
ID:	179704   Click image for larger version

Name:	4.png
Views:	104
Size:	15.2 KB
ID:	179705  
dunhill is offline   Reply With Quote
Old 06-04-2020, 01:43 AM   #9
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by dunhill View Post
Davidfor!
We are close the two codes work half, let's say
I don't know why because the "V. Decimal" column has no format or code. I leave catches.
The use of comma or dot is a locale thing. Australia and I think most English speaking countries use a dot with the comma as the thousands separator. And from memory, most European use a comma for the decimals and spaces for the thousands.
Quote:
If the column has a value it is ok to put yes.
And it is expected that if it is empty it will put No but yes.
I don't want to be annoying, if you can't. I forget about those settings. Thank you very much for your time and for the prompt responses.
My quick and dirty cheat is to return a value that triggers the appropriate response if the column is empty.

Code:
program:
cmp(list_item(ifempty(field('#gr1'),'0,1'),1,','),0,'','Yes','');
That should work assuming I changed from my test version to yours properly.

@chaley: I tried the raw_list, but, it gave me the error "is not a list".
davidfor is offline   Reply With Quote
Old 06-04-2020, 02:43 AM   #10
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: 11,741
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by davidfor View Post
@chaley: I tried the raw_list, but, it gave me the error "is not a list".
Ahh, you are right. Looking at the first post, #gr1 is a floating point number. Sorry about the noise.
chaley is offline   Reply With Quote
Old 06-04-2020, 06:34 AM   #11
dunhill
Guru
dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.
 
dunhill's Avatar
 
Posts: 723
Karma: 228142
Join Date: Sep 2017
Location: Argentina
Device: moon+ reader, kindle paperwhite
Quote:
Originally Posted by davidfor View Post
The use of comma or dot is a locale thing. Australia and I think most English speaking countries use a dot with the comma as the thousands separator. And from memory, most European use a comma for the decimals and spaces for the thousands.


My quick and dirty cheat is to return a value that triggers the appropriate response if the column is empty.

Code:
program:
cmp(list_item(ifempty(field('#gr1'),'0,1'),1,','),0,'','Yes','');
That should work assuming I changed from my test version to yours properly.

@chaley: I tried the raw_list, but, it gave me the error "is not a list".

Yes now!!!! Genius thank you very much !!!
Thanks also to @chaley for the suggestions
dunhill 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
Help with template... or something else Glottis Library Management 5 10-07-2015 12:55 PM
need help with nested template Jade Aislin Library Management 2 11-30-2012 02:04 AM
Help with template language Pepin33 Calibre 8 11-11-2012 08:32 AM
Help with template KALKITO Library Management 1 07-02-2012 02:54 PM


All times are GMT -4. The time now is 10:49 AM.


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