![]() |
#1 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,802
Karma: 74203799
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Testing for specific number in a psuedobool composite
I currently have this template for a psuedobool* #currentlyreading:
Code:
program: test(check_yes_no('#read', 0, 1, 0), test(field('#lastread'), 'Yes', ''), '') * composites that return a value for "Show Checkmark" option ![]() Last edited by ownedbycats; 02-24-2021 at 04:32 AM. |
![]() |
![]() |
![]() |
#2 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,364
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
I am not sure what you want to do, but this might be enough of a pattern for you to work it out.
Code:
program: if and( check_yes_no('#read', '', 1, ''), field('#lastread'), field('#percentread') ># 0 ) then 'Yes' fi |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,802
Karma: 74203799
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
I had to modify it a bit. The pound sign broke it, and I actually wanted >1 to get it to work the way I wanted.
Code:
program: if and( check_yes_no('#read', '', 1, ''), field('#lastread'), field('#percentread') >1 ) then 'Yes' fi Last edited by ownedbycats; 02-24-2021 at 02:50 PM. |
![]() |
![]() |
![]() |
#4 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,364
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Assuming that #percentread is a numeric column then you need the #. If you don't have it then it uses a lexical compare where '3' is larger than '20'.
If #percentread is formatted then you need to use raw_field() to get the underlying number without any extra characters. |
![]() |
![]() |
![]() |
#5 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,802
Karma: 74203799
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
#percentread is interger formatted as {0}%.
|
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,364
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
raw_field('#percentread') will give you the underlying number without formatting.
When using raw_field, undefined numeric fields are assumed to have a value of zero. If this isn't acceptable then use Code:
and(field('#percentread'), raw_field('#percentread') ># 1) |
![]() |
![]() |
![]() |
#7 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,802
Karma: 74203799
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Since I am testing that the number is higher than 0, having an undefined of 0 works ok.
![]() |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Using RE to extract pattern from custom column into another custom column | activedirectory | Library Management | 1 | 12-15-2019 08:07 PM |
Adding custom column with any lookup-name gives me empty column as a result? | Ahu Lee | Library Management | 16 | 06-09-2019 12:14 PM |
Move selected data from series column to a new custom column | fvdham | Library Management | 3 | 06-02-2017 03:49 PM |
Custom column returns value based on value of another custom column? | calvin-c | Calibre | 3 | 09-14-2013 02:24 PM |
Modifying column display | ccayer | Calibre | 11 | 05-11-2010 06:18 AM |