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 12-25-2020, 06:13 PM   #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,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
This has error of a missing fi. Got EOF errors trying to figure out where it goes. Where do I put it?

Last edited by ownedbycats; 12-25-2020 at 06:31 PM.
ownedbycats is offline   Reply With Quote
Old 12-25-2020, 06:56 PM   #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,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?
ownedbycats is offline   Reply With Quote
Advert
Old 12-25-2020, 07:04 PM   #3
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,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
I'm still not sure if that is correct as there is a path through it that will does not return an icon name. I can't tell if that is deliberate, means it isn't complete or I've missed something.
davidfor is offline   Reply With Quote
Old 12-25-2020, 07:36 PM   #4
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,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:

Click image for larger version

Name:	2020-12-25 20_59_46-Window.png
Views:	72
Size:	10.4 KB
ID:	184265

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'
Even with the missing fi added, I messed up the template a bit as it instead returns reader.png for everything.

Last edited by ownedbycats; 12-25-2020 at 08:17 PM.
ownedbycats is offline   Reply With Quote
Old 12-25-2020, 08:25 PM   #5
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,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
I haven't used the "check_yes_no" function before, but the first parameter is the column lookup name, not the value. From your "#onkobo" column is a Yes/No column, not a column containing the name of some other column.

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.
davidfor is offline   Reply With Quote
Advert
Old 12-25-2020, 08:30 PM   #6
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,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.
ownedbycats is offline   Reply With Quote
Old 12-25-2020, 09:16 PM   #7
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,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
But, that "if" isn't needed:
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
davidfor is offline   Reply With Quote
Old 12-25-2020, 09:56 PM   #8
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,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.
ownedbycats is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
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


All times are GMT -4. The time now is 04:25 AM.


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