![]() |
#1 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,969
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Missing fi in if/then/else statement
Code:
program: if check_yes_no(field('#onkobo'), '', '1', '') then 'sync.png' else if check_yes_no(field('#onkobo'), '', '', '1') then if str_in_list(field('#kobocoll'), ',', "Kobo Store", '1', '') then 'drm-locked.png' fi else 'reader.png' fi ![]() Last edited by ownedbycats; 12-25-2020 at 06:31 PM. |
![]() |
![]() |
![]() |
#2 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,969
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
I had to add an extra fi to the end. Except now every single book is showing reader.png.
What did I mess up? |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
Right at the end. You don't have an "fi" to match the first "if". Or at least that is what I think it is. It felt like there was a couple of possibilities as I wasn't completely sure what it doing.
The way I would indent this is: Code:
program: if check_yes_no(field('#onkobo'), '', '1', '') then 'sync.png' else if check_yes_no(field('#onkobo'), '', '', '1') then if str_in_list(field('#onkobo'), ',', "Kobo Store", '1', '') then 'drm-locked.png' fi else 'reader.png' fi fi |
![]() |
![]() |
![]() |
#4 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,969
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Here are the three rules I was trying to replace:
What I was trying to do, using boolean search syntax in place of the template: Code:
if #onkobo:no, then 'sync.png' else if #onkobo:yes, then if #kobocoll:"=Kobo Store" then 'drm-locked.png' else 'reader.png' Last edited by ownedbycats; 12-25-2020 at 08:17 PM. |
![]() |
![]() |
![]() |
#5 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
In that case:
Code:
program: if check_yes_no('#onkobo', 0, 1, 0) then 'sync.png' else if check_yes_no('#onkobo', 0, 0, 1) then if str_in_list(field('#kobocoll'), ',', "Kobo Store", 1, 0) then 'drm-locked.png' else 'reader.png' fi fi fi And for readability, not wrapping the numbers in quotes works better for me. It tells me we are after the numbers, not strings that could be something else. And then seeing them as Booleans is easier. But, I don't know what happens performance-wise. |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,969
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
I tested that. #onkobo:undefined and #onkobo:no work as expected, but #onkobo:yes returns drm-locked.png even if not #kobocoll:"=Kobo Store". Hmmm.
|
![]() |
![]() |
![]() |
#7 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
The result of "str_in_list" isn't returning something that is being interpreted as a Boolean. The following works:
Code:
program: if check_yes_no('#onkobo', 0, 1, 0) then 'sync.png' else if check_yes_no('#onkobo', 0, 0, 1) then if str_in_list(field('#kobocoll'), ',', "Kobo Store", 1, 0) == 1 then 'drm-locked.png' else 'reader.png' fi fi fi Code:
program: if check_yes_no('#onkobo', 0, 1, 0) then 'sync.png' else if check_yes_no('#onkobo', 0, 0, 1) then str_in_list(field('#kobocoll'), ',', "Kobo Store", 'drm-locked.png', 'reader.png') fi fi |
![]() |
![]() |
![]() |
#8 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,969
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
That works. Thank you!
Templates honestly are difficult for me to understand. I've mostly just been reverse-engineering existing examples (either posted here on MR or with the new convert-to-advanced-rule button) and using the documentation to try to figure out how to make a round peg fit into a square hole. ![]() |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
IF statement in virtual libraries | sbin | Library Management | 5 | 11-01-2016 05:34 AM |
set up an IF statement | mom34spartan | Library Management | 1 | 01-29-2014 01:10 PM |
underwhelming statement | Namekuseijin | Amazon Kindle | 6 | 08-08-2013 07:12 PM |
A Statement about Froyo | dontpanic | enTourage Archive | 236 | 03-29-2011 07:48 PM |
Accessories Fashion statement | Kumabjorn | Amazon Kindle | 27 | 09-08-2010 06:39 AM |