![]() |
#316 | ||
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,509
Karma: 8065348
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Code:
program: if '(Archive of Our Own|Fanfiction.net)' in $publisher && '(Completed|Abandoned|Oneshot|Incomplete)' in status then "metadata.png" elif (!select(ids, 'ao3') && $publisher == 'Archive of Our Own' && status == 'In-Progress' ) || (!select(ids, 'ffnet') && $publisher == 'FanFiction.net' && status == 'In-Progress') then "metadata.png" fi Quote:
It should look like this: Code:
program: first_non_empty( if $title then 'title' fi, <==== comma here if $authors then 'authors' fi ) |
||
![]() |
![]() |
![]() |
#317 | |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,162
Karma: 77304081
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Quote:
![]() Code:
elif (status == 'In-Progress' && (!select(ids, 'ao3') && $publisher == 'Archive of Our Own') || (!select(ids, 'ffnet') && $publisher == 'FanFiction.net') ) then "metadata.png" |
|
![]() |
![]() |
![]() |
#318 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,509
Karma: 8065348
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Code:
program: if ( status == 'In-Progress' && (!select(ids, 'ao3') && $publisher == 'Archive of Our Own') ) || ( (!select(ids, 'ffnet') && $publisher == 'FanFiction.net') ) then "metadata.png" fi Code:
program: if status == 'In-Progress' && ( (!select(ids, 'ao3') && $publisher == 'Archive of Our Own') || (!select(ids, 'ffnet') && $publisher == 'FanFiction.net') ) then "metadata.png" fi My advice: don't depend on operator precedence unless you really know what you are doing. Instead use parentheses to specify the order of evaluation. EDIT: I forgot to mention: factoring conditions in ifs is a very good thing for performance and readability. It makes the flow clearer and takes maximum advantage of condition short circuiting. Good that you noticed it. ![]() Last edited by chaley; 01-29-2022 at 10:45 AM. |
|
![]() |
![]() |
![]() |
#319 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,162
Karma: 77304081
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
The downside of nesting ifs is that it's very easy to misplace fis. I've gotten into the habit of adding ## Start/End [something] check comments just so I remember what they belong to.
|
![]() |
![]() |
![]() |
#320 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,509
Karma: 8065348
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
One trick you can use to match a fi with its if. Put a left parenthesis in front of the if. The editor will complain about a syntax error. Now put a right parenthesis after the fi that you think matches (but before any semicolon). If the error goes away then they indeed match. If there is still an error then the if and fi don't match. |
|
![]() |
![]() |
![]() |
#321 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,162
Karma: 77304081
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
That will be useful to know
![]() Also, something like this Code:
if variable == 'foo' && anothervariable && thirdvariable != 'bar' then 'foobar' |
![]() |
![]() |
![]() |
#322 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,162
Karma: 77304081
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Does if $#columname== '' work for all undefined columntypes? (excluding the default columns 'title' and 'author')
Last edited by ownedbycats; 01-31-2022 at 07:55 PM. |
![]() |
![]() |
![]() |
#323 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,509
Karma: 8065348
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Note that !$#mumble is equivalent to $#mumble=='' but faster. |
|
![]() |
![]() |
![]() |
#324 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,162
Karma: 77304081
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
EDIT: It was a regex error.
Last edited by ownedbycats; 02-02-2022 at 12:01 AM. |
![]() |
![]() |
![]() |
#325 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,162
Karma: 77304081
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Not quite a template question, but did I make a mistake on this saved search? I'm getting VL recursion errors:
Code:
NOT formats:(paperbook|overdrive) OR NOT formats:#=1 Last edited by ownedbycats; 02-03-2022 at 09:22 PM. |
![]() |
![]() |
![]() |
#326 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,162
Karma: 77304081
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Code:
program: strcat( icons_readstatus(), icons_fanfic(), icons_devicestatus(), icons_formats(), ) ![]() |
![]() |
![]() |
![]() |
#327 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,509
Karma: 8065348
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Code:
program: strcat( icons_readstatus(), ':', icons_fanfic(), ':', icons_devicestatus(), ':', icons_formats(), ) |
|
![]() |
![]() |
![]() |
#328 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,162
Karma: 77304081
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Silly question:
I have this rule in emblems: Code:
program: first_non_empty( icons_cleanup_metadata(), icons_cleanup_missingids(), icons_cleanup_fanfic(), icons_marked(), if 'Cleanup' in virtual_libraries() then 'polish.png' fi ) So I tried replacing with if is_marked() then '' fi and... wait, that's an empty: Invis.png doesn't really work quite as expected either: Is there a better option than first_non_empty? For now, I'm using if is_marked() then 'nope' fi as that won't render anything. Last edited by ownedbycats; 02-04-2022 at 08:20 AM. |
![]() |
![]() |
![]() |
#329 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,509
Karma: 8065348
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Code:
program: if v = icons_cleanup_metadata() then v elif v = icons_cleanup_missingids() then v elif v = icons_cleanup_fanfic() then v elif v = icons_marked() then v elif 'Cleanup' in virtual_libraries() then 'polish.png' fi With your change the icons_marked line would become Code:
elif is_marked() then '' The two 'tricks' are:
|
|
![]() |
![]() |
![]() |
#330 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,509
Karma: 8065348
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
BTW: you can also do it using a series of ifs with return statements as long as you don't do any processing after the last one.
Code:
program: if v = icons_cleanup_metadata() then return v fi; if v = icons_cleanup_missingids() then return v fi; if v = icons_cleanup_fanfic() then return v fi; if is_marked() then return '' fi; if 'Cleanup' in virtual_libraries() then return 'polish.png' fi |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Library Management: various questions not worth their own thread | ownedbycats | Library Management | 234 | 08-22-2025 05:42 AM |
[Metadata Source Plugin] Questions regarding parse select, docs and ref templates | Boilerplate4U | Development | 13 | 07-07-2020 02:35 AM |
Questions on Kobo [Interfered with another thread topic] | spdavies | Kobo Reader | 8 | 10-12-2014 11:37 AM |
[OLD Thread] Some questions before buying the fire. | darthreader13 | Kindle Fire | 7 | 05-10-2013 09:19 PM |
Thread management questions | meme | Feedback | 6 | 01-31-2011 05:07 PM |