![]() |
#16 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,908
Karma: 7076137
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
|
![]() |
![]() |
![]() |
#17 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,207
Karma: 63194629
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
That makes sense, though it's also a bit confusing because searching #bool:true and #bool:false will check that they're defined/undefined.
Last edited by ownedbycats; 04-03-2021 at 05:28 AM. |
![]() |
![]() |
Advert | |
|
![]() |
#18 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,908
Karma: 7076137
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Also and FWIW: in your template you can also return '1' for True and '0' for False. |
|
![]() |
![]() |
![]() |
#19 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,133
Karma: 1954142
Join Date: Aug 2015
Device: Kindle
|
Both will work (yes/no & true/false) with Action Chains. But better to stick with the Yes/No to be in line with what Calibre uses for the column. Also 0/1 will work.
|
![]() |
![]() |
![]() |
#20 | |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,207
Karma: 63194629
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Quote:
now I am curious, how does searching for #bool:yes/no work with translations? |
|
![]() |
![]() |
Advert | |
|
![]() |
#21 | ||
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,908
Karma: 7076137
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Quote:
First the local (translated) words are determined. This is for English.
Last edited by chaley; 04-03-2021 at 02:29 PM. |
||
![]() |
![]() |
![]() |
#22 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,207
Karma: 63194629
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
When doing a check_yes_no, I noticed that 1, '', '' and 1, 0, 0 both worked. Is there a difference between 0 and null?
Last edited by ownedbycats; 04-03-2021 at 11:44 PM. |
![]() |
![]() |
![]() |
#23 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,908
Karma: 7076137
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Code:
check_yes_no(#a, 'Klingons', 'rule', 1) Code:
check_yes_no(#a, 0, 0, 1) |
|
![]() |
![]() |
![]() |
#24 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,207
Karma: 63194629
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Should local variables work for check_yes_no?
e.g. Code:
program: k = $$#kobocoll; o = field('#onkobo'); if check_yes_no(o, 0, 1, 0) then 'sync.png' elif check_yes_no(o, 0, 0, 1) then if list_contains(k, ',', '^Kobo Store$', '1', '') then 'drm-locked.png' elif list_contains(k, ',', '^Send to Device$', '1', '') then 'sync.png' else 'reader.png' fi fi Last edited by ownedbycats; 04-05-2021 at 06:21 AM. |
![]() |
![]() |
![]() |
#25 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,908
Karma: 7076137
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
No, not in the way you think. Because check_yes_no() needs the raw value it requires the name of the field, not the value of the field. Thus this will work
Code:
program: f = '#mybool'; check_yes_no(f, 1, 1, 1) Code:
program: f = $#mybool; check_yes_no(f, 1, 1, 1) Code:
program: # must use raw_field() f = $$#mybool; # A bool column fetched with raw_field will have 1 of 3 values, True, False, or None if f == 'true' then 'yes' elif f == 'false' then 'no' elif f == 'none' then 'undefined' else 'what?' fi Code:
program: # must use raw_field() f = $$#mybool; first_non_empty( test(f == 'true', 'yes', ''), test(f == 'false', 'no', ''), test(f == 'none', 'undefined', '') ) |
![]() |
![]() |
![]() |
#26 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,207
Karma: 63194629
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
I put o = '#onkobo'; and that worked.
![]() Question: Could a stored template be used to share the same code between a column icon and emblem? I saved some templates I have in both places (reading_status, kobo_status, and format_icons) but I am not quite sure how to get them to work. The dialog says to use the 'call' function but I think I did it wrong as I just got an error about it being unknown. Last edited by ownedbycats; 04-05-2021 at 09:44 PM. |
![]() |
![]() |
![]() |
#27 | ||
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,908
Karma: 7076137
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Quote:
You use a stored template just as you use a template function, stored_template_name(args). If you update source you will see some improvements in the stored template dialog. The most important is there is now a "test" button that opens a subsidiary template tester so you can try the stored template(s) without leaving the preferences dialog. Example of definition and use of a stored template: Definition: The program text: Code:
program: arguments(lst='No list argument given', items=''); r = ''; for l in items: if !r then r = str_in_list(lst, ',', l, l, '') fi rof; if !r then r = sublist(list_sort(lst, 0, ','), 0, 1, ',') fi; r; Code:
program: list_priority_item($tags, 'foo') |
||
![]() |
![]() |
![]() |
#28 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,207
Karma: 63194629
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Thank you
![]() How do I add a comment to a template? Sometimes I forget what specific parts of a GPM template are meant to do. |
![]() |
![]() |
![]() |
#29 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,908
Karma: 7076137
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
|
![]() |
![]() |
![]() |
#30 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,207
Karma: 63194629
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Thank you.
![]() How do I escape a forward slash? the first if of this statement isn't working for me. I tried adding a second slash to escape it but it errored too. Code:
program: if $$#fanficcat then list_re($tags, ',', '\.', '!') elif $formats == 'PDF' then 'PDF' else list_re($tags, ',', '^(.*?)($|\..*$)', '\1') fi ![]() Last edited by ownedbycats; 04-12-2021 at 04:27 PM. |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Library Management: various questions not worth their own thread | ownedbycats | Library Management | 156 | 07-23-2024 11:45 PM |
[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 |