|  04-03-2021, 05:15 AM | #16 | 
| Grand Sorcerer            Posts: 12,525 Karma: 8065948 Join Date: Jan 2010 Location: Notts, England Device: Kobo Libra 2 | |
|   |   | 
|  04-03-2021, 05:24 AM | #17 | 
| Custom User Title            Posts: 11,342 Karma: 79528341 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. | 
|   |   | 
|  04-03-2021, 05:46 AM | #18 | |
| Grand Sorcerer            Posts: 12,525 Karma: 8065948 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. | |
|   |   | 
|  04-03-2021, 05:59 AM | #19 | 
| Wizard            Posts: 1,216 Karma: 1995558 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.
		 | 
|   |   | 
|  04-03-2021, 06:52 AM | #20 | |
| Custom User Title            Posts: 11,342 Karma: 79528341 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? | |
|   |   | 
|  04-03-2021, 08:30 AM | #21 | ||
| Grand Sorcerer            Posts: 12,525 Karma: 8065948 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. | ||
|   |   | 
|  04-03-2021, 11:40 PM | #22 | 
| Custom User Title            Posts: 11,342 Karma: 79528341 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. | 
|   |   | 
|  04-04-2021, 04:28 AM | #23 | |
| Grand Sorcerer            Posts: 12,525 Karma: 8065948 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) | |
|   |   | 
|  04-05-2021, 05:51 AM | #24 | 
| Custom User Title            Posts: 11,342 Karma: 79528341 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
fiLast edited by ownedbycats; 04-05-2021 at 06:21 AM. | 
|   |   | 
|  04-05-2021, 06:59 AM | #25 | 
| Grand Sorcerer            Posts: 12,525 Karma: 8065948 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', '') ) | 
|   |   | 
|  04-05-2021, 09:34 PM | #26 | 
| Custom User Title            Posts: 11,342 Karma: 79528341 Join Date: Oct 2018 Location: Canada Device: Kobo Libra H2O, formerly Aura HD | 
			
			I put o = '#onkobo'; and that worked.   I will remember that. 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. | 
|   |   | 
|  04-06-2021, 05:27 AM | #27 | ||
| Grand Sorcerer            Posts: 12,525 Karma: 8065948 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') | ||
|   |   | 
|  04-08-2021, 02:54 PM | #28 | 
| Custom User Title            Posts: 11,342 Karma: 79528341 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. | 
|   |   | 
|  04-08-2021, 03:01 PM | #29 | 
| Grand Sorcerer            Posts: 12,525 Karma: 8065948 Join Date: Jan 2010 Location: Notts, England Device: Kobo Libra 2 | |
|   |   | 
|  04-12-2021, 02:15 PM | #30 | 
| Custom User Title            Posts: 11,342 Karma: 79528341 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 This is for my #kobopath composite for a save template. Last edited by ownedbycats; 04-12-2021 at 04:27 PM. | 
|   |   | 
|  | 
| Thread Tools | Search this Thread | 
| 
 | 
|  Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post | 
| Library Management: various questions not worth their own thread | ownedbycats | Library Management | 253 | 10-21-2025 08:15 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 | Amazon Fire | 7 | 05-10-2013 09:19 PM | 
| Thread management questions | meme | Feedback | 6 | 01-31-2011 05:07 PM |