View Single Post
Old 12-26-2021, 01:44 PM   #251
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,458
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Code:
program:
m = is_marked();

first_non_empty
   (
    contains(m, "invalid_author_sort|invalid_title_sort", 'auto_author_sort.png', ''),
    contains(m, "epub_calibre_bookmarks", 'snippets.png', ''),
    if 'fff' in m && check_yes_no($#onkobo, 0, 0, 1) then 'sync.png' fi,
    contains(m, "fff", 'download-metadata.png', ''),
    contains(m, "search_results", 'search.png', ''),
    if m then 'marked.png' fi
   )
I'm likely going about this the wrong way - line 8 I want to check the book is marked with fff and #onkobo is set to yes. But instead I'm getting download_metadata.png on those ones.

Any idea?
Your problem is that check_yes_no() takes a field name not a field value. The line should be
Code:
    if 'fff' in m && check_yes_no('#onkobo', 0, 0, 1) then 'sync.png' fi,
Also, it might be that you want list_contains() (also named in_list()) instead of contains(). This is true if there is any chance that 'm' can contain items that contain queried terms. For example, contains() will return True if the query term is 'fff' and the value is fff_good. Contains() is fine if no submatches are possible.

EDIT: You can also use str_in_list() to do exact matching if you don't need regular expressions. For example, this
Code:
contains(m, "invalid_author_sort|invalid_title_sort", 'auto_author_sort.png', ''),
can be written as
Code:
str_in_list(m, ',', 'invalid_author_sort', 'auto_author_sort.png', 'invalid_title_sort', 'auto_author_sort.png', ''),
Also like this:
Code:
if '^(invalid_author_sort|invalid_title_sort)$' inlist m then 'auto_author_sort.png' fi,

Last edited by chaley; 12-26-2021 at 02:02 PM.
chaley is offline   Reply With Quote