Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 04-03-2021, 05:15 AM   #16
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: 11,791
Karma: 7029971
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
When using a template in Action Chains to set a boolean column, should I use "Yes/No" or "True/False"?
Either one.

True/False have a small advantage; they work in all languages. Yes/No are translated.

NB: use '' to set it to undefined.
chaley is offline   Reply With Quote
Old 04-03-2021, 05:24 AM   #17
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 8,850
Karma: 62032373
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.
ownedbycats is offline   Reply With Quote
Advert
Old 04-03-2021, 05:46 AM   #18
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: 11,791
Karma: 7029971
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
That makes sense, though it's also a bit confusing because searching #bool:true and #bool:false will check that they're defined/undefined.
Because in search that is what true and false mean for all column types. True checks for "has any value". False checks for "has no value". The boolean False is a value under those rules.

Also and FWIW: in your template you can also return '1' for True and '0' for False.
chaley is offline   Reply With Quote
Old 04-03-2021, 05:59 AM   #19
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,120
Karma: 1954138
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.
capink is offline   Reply With Quote
Old 04-03-2021, 06:52 AM   #20
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 8,850
Karma: 62032373
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Quote:
Originally Posted by chaley View Post
Because in search that is what true and false mean for all column types. True checks for "has any value". False checks for "has no value". The boolean False is a value under those rules.

Also and FWIW: in your template you can also return '1' for True and '0' for False.
I also noticed that when I used bistate booleans, true/false also worked the same as yes/no. I had to fix a bunch of saved searches when I switched to tristate.

now I am curious, how does searching for #bool:yes/no work with translations?
ownedbycats is offline   Reply With Quote
Advert
Old 04-03-2021, 08:30 AM   #21
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: 11,791
Karma: 7029971
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
I also noticed that when I used bistate booleans, true/false also worked the same as yes/no. I had to fix a bunch of saved searches when I switched to tristate.
That is because bistate bools are implemented using tristate. Undefined is used for the False value.
Quote:
now I am curious, how does searching for #bool:yes/no work with translations?
The rules from the code:

First the local (translated) words are determined. This is for English.
  • self.local_no = icu_lower(_('no'))
  • self.local_yes = icu_lower(_('yes'))
  • self.local_unchecked = icu_lower(_('unchecked'))
  • self.local_checked = icu_lower(_('checked'))
  • self.local_empty = icu_lower(_('empty'))
  • self.local_blank = icu_lower(_('blank'))
The comparisons are below. The quoted strings are literal, not translated.
  • Value 'True': self.local_yes, self.local_checked, 'checked', '_checked', 'yes', '_yes', 'true'
  • Value 'False':self.local_no, self.local_unchecked, 'unchecked', '_unchecked', 'no', '_no', 'true'
  • Value Undefined: self.local_empty, self.local_blank, 'blank', '_blank', 'empty', '_empty', 'false'
To head off the inevitable next question, '_yes' etc exist because it is possible the the translation of (for example) 'Empty' is 'Yes'. The words 'true' and 'false' are reserved.

Last edited by chaley; 04-03-2021 at 02:29 PM.
chaley is offline   Reply With Quote
Old 04-03-2021, 11:40 PM   #22
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 8,850
Karma: 62032373
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.
ownedbycats is offline   Reply With Quote
Old 04-04-2021, 04:28 AM   #23
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: 11,791
Karma: 7029971
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
When doing a check_yes_no, I noticed that 1, '', '' and 1, 0, 0 both worked. Is there a difference between 0 and null?
The function checks '1' for 'True'. Anything else is False. Thus
Code:
check_yes_no(#a, 'Klingons', 'rule', 1)
is equivalent to
Code:
check_yes_no(#a, 0, 0, 1)
chaley is offline   Reply With Quote
Old 04-05-2021, 05:51 AM   #24
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 8,850
Karma: 62032373
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
results in null values where putting in the check_yes_no('#onkobo', x, x, x) gives results

Last edited by ownedbycats; 04-05-2021 at 06:21 AM.
ownedbycats is offline   Reply With Quote
Old 04-05-2021, 06:59 AM   #25
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: 11,791
Karma: 7029971
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Should local variables work for check_yes_no?
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)
but this will not. The value is always considered to be undefined.
Code:
program:
	f = $#mybool;
	check_yes_no(f, 1, 1, 1)
If you want to use a local variable containing a value then you must do something like this:
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
Another way of saying the above is
Code:
program:
# must use raw_field()
	f = $$#mybool;
	first_non_empty(
		test(f == 'true', 'yes', ''),
		test(f == 'false', 'no', ''),
		test(f == 'none', 'undefined', '')
	)
chaley is offline   Reply With Quote
Old 04-05-2021, 09:34 PM   #26
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 8,850
Karma: 62032373
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.
ownedbycats is offline   Reply With Quote
Old 04-06-2021, 05:27 AM   #27
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: 11,791
Karma: 7029971
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Question: Could a stored template be used to share the same code between a column icon and emblem?
Yes.
Quote:
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.
The documentation is wrong. I will fix it.

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:
Click image for larger version

Name:	Clipboard01.jpg
Views:	302
Size:	51.9 KB
ID:	186442
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;
How to call it
Code:
program: list_priority_item($tags, 'foo')
chaley is offline   Reply With Quote
Old 04-08-2021, 02:54 PM   #28
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 8,850
Karma: 62032373
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.
ownedbycats is offline   Reply With Quote
Old 04-08-2021, 03:01 PM   #29
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: 11,791
Karma: 7029971
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
How do I add a comment to a template? Sometimes I forget what specific parts of a GPM template are meant to do.
Comments are lines starting with a ‘#’ character. Comments beginning later in a line are not supported.
chaley is offline   Reply With Quote
Old 04-12-2021, 02:15 PM   #30
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 8,850
Karma: 62032373
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
Also, how would you apply a sublist of just first item to the list_re? See the third item in the screenshot. I tried enclosing it but I broke it. This is for my #kobopath composite for a save template.
Attached Thumbnails
Click image for larger version

Name:	2021-04-12 17_25_13-Template tester.png
Views:	311
Size:	32.2 KB
ID:	186571  

Last edited by ownedbycats; 04-12-2021 at 04:27 PM.
ownedbycats is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Library Management: various questions not worth their own thread ownedbycats Library Management 153 05-14-2024 01:30 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


All times are GMT -4. The time now is 11:38 PM.


MobileRead.com is a privately owned, operated and funded community.