04-12-2021, 05:20 PM | #31 |
Custom User Title
Posts: 9,575
Karma: 64960983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Also while making that template I noticed if I accidentally put $$fanficcat (which is a column that does not exist), the first clause returned for every book. Is this intended?
|
04-12-2021, 05:46 PM | #32 | |
Grand Sorcerer
Posts: 12,038
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Do you mean the slashes in this statement?
Code:
list_re($tags, ',', '\.', '\') Unfortunately the regexp-based template language lexical analyser cannot handle escaped backslashes. To do what you want you must use some other character. Quote:
Code:
re(sublist($tags, 0, 1, ','), '^(.*?)($|\..*$)', '\1') Last edited by chaley; 04-12-2021 at 06:03 PM. Reason: Correct the argument order for sublist |
|
Advert | |
|
04-12-2021, 05:46 PM | #33 |
Grand Sorcerer
Posts: 12,038
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
|
04-12-2021, 05:59 PM | #34 |
Custom User Title
Posts: 9,575
Karma: 64960983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
I found a post saying that both slashes could be used and it'll be normalized, so I switched it:
Code:
program: if $$#fanficcat then re(sublist($tags, ',', 0, 1), '\.', '/') elif $formats == 'PDF' then 'PDF' else re(sublist($tags, ',', 0, 1), '^(.*?)($|\..*$)', '\1') fi |
04-12-2021, 06:02 PM | #35 | |
Grand Sorcerer
Posts: 12,038
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Code:
sublist(list_string, start_index, end_index, separator) |
|
Advert | |
|
04-12-2021, 06:06 PM | #36 |
Custom User Title
Posts: 9,575
Karma: 64960983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Code:
program: # Returns 'Fanfiction/Fandom' for fanfics if $$#fanficcat then re(sublist($tags, 0, 1, ','), '\.', '/') # Returns 'PDF' for PDFs elif $formats == 'PDF' then 'PDF' # Returns topmost tag for all other books else re(sublist($tags, 0, 1, ','), '^(.*?)($|\..*$)', '\1') fi Last edited by ownedbycats; 04-12-2021 at 06:08 PM. |
04-13-2021, 02:35 PM | #37 |
Custom User Title
Posts: 9,575
Karma: 64960983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Question: If you have two if statements that are mutually exclusive:
Code:
program: if $#enum== 'foo' then 'foo' else $#enum == 'bar' then 'bar' fi Last edited by ownedbycats; 04-13-2021 at 02:38 PM. |
04-13-2021, 02:53 PM | #38 |
Grand Sorcerer
Posts: 12,038
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Functionally, no, as long as you can truly guarantee mutual exclusivity. However, there might be differences in performance. The most common ones should be first.
|
04-13-2021, 07:41 PM | #39 | |
Custom User Title
Posts: 9,575
Karma: 64960983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
In regards to this:
Quote:
|
|
04-13-2021, 07:49 PM | #40 |
Grand Sorcerer
Posts: 12,038
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Your bug report was about multiple book search and replace. That dialog in regexp mode supports "Template" as the source field.
|
04-13-2021, 08:02 PM | #41 |
Custom User Title
Posts: 9,575
Karma: 64960983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
I see it now.
|
04-14-2021, 05:06 PM | #42 |
Custom User Title
Posts: 9,575
Karma: 64960983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Question: Can a gpm statement be used for a save template?
I currently have a #kobopath gpm composite which then passes itself into my save templates; I thought I could skip that intermediary step. Last edited by ownedbycats; 04-14-2021 at 05:14 PM. |
04-14-2021, 06:56 PM | #43 | |
Grand Sorcerer
Posts: 12,038
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Why? These templates predate the template language by several years. |
|
04-14-2021, 06:59 PM | #44 |
Custom User Title
Posts: 9,575
Karma: 64960983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Ok. That's good to know that before I started trying to kludge something together.
|
04-16-2021, 02:07 AM | #45 |
Custom User Title
Posts: 9,575
Karma: 64960983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
This (it's still a WIP; I am still debating whether this will be better than multiple non-template rules) returns a syntax error about an unexpected end of program near "unknown." Where exactly is the mistake?
Code:
program: vl = $#vls; pc = $$#pagecount; fmt = $$#formats; lang = $$#languages if 'Cleanup' in vl then # Checks for a missing format if fmt == '' then 'add_book.png' fi # Checks for a missing pagecount if pc == 'None' then 'cover_flow.png' fi # Checks for a missing language if lang == 'None' then 'languages.png' fi # Checks for an ORIGINAL_EPUB in formats if fmt == 'ORIGINAL_EPUB' then 'add_book.png' fi # Returns a generic icon if no specific issue is flagged else 'polish.png' fi Last edited by ownedbycats; 04-16-2021 at 02:18 AM. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Library Management: various questions not worth their own thread | ownedbycats | Library Management | 178 | 11-12-2024 03:14 PM |
[Metadata Source Plugin] Questions regarding parse select, docs and ref templates | Boilerplate4U | Development | 13 | 07-07-2020 03:35 AM |
Questions on Kobo [Interfered with another thread topic] | spdavies | Kobo Reader | 8 | 10-12-2014 12:37 PM |
[OLD Thread] Some questions before buying the fire. | darthreader13 | Kindle Fire | 7 | 05-10-2013 10:19 PM |
Thread management questions | meme | Feedback | 6 | 01-31-2011 06:07 PM |