Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 03-31-2021, 10:09 AM   #1
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,553
Karma: 61170925
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Templates: various questions not worth their own thread

I'll try to use this thread for smaller questions to avoid spamming up this section even more.

Is there any semantic difference between

Code:
"foobar" in #column
and

Code:
#column in "foobar"
They seem to have the same results when I used them in a GPM template.
ownedbycats is offline   Reply With Quote
Old 03-31-2021, 11:45 AM   #2
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,733
Karma: 6690881
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
I'll try to use this thread for smaller questions to avoid spamming up this section even more.

Is there any semantic difference between

Code:
"foobar" in #column
and

Code:
#column in "foobar"
They seem to have the same results when I used them in a GPM template.
They are very different. Consider what happens if
Code:
#column == 'foobar is a strange word'
The first test would succeed. The second test would not.

If in your situation the two always both succeed then you probably should be using '==' instead of 'in'. EDIT: Or one of the list operators.

Last edited by chaley; 03-31-2021 at 02:43 PM.
chaley is offline   Reply With Quote
Advert
Old 03-31-2021, 04:33 PM   #3
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,553
Karma: 61170925
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
In my case, I was doing this:

Code:
&& publisher == '(Archive of Our Own|FanFiction.net)'
"that doesn't work, i'll try an in instead," so:

Code:
&& publisher in '(Archive of Our Own|FanFiction.net)'
"that gets the right result but looks backwards, will it work the other way?"

Code:
&& '(Archive of Our Own|FanFiction.net)' in publisher
ownedbycats is offline   Reply With Quote
Old 03-31-2021, 04:47 PM   #4
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,733
Karma: 6690881
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
In my case, I was doing this:

Code:
&& publisher == '(Archive of Our Own|FanFiction.net)'
"that doesn't work, i'll try an in instead," so:

Code:
&& publisher in '(Archive of Our Own|FanFiction.net)'
"that gets the right result but looks strange, will it work the other way?"

Code:
&& '(Archive of Our Own|FanFiction.net)' in publisher
The "other way" is the right one. A regexp pattern works only if it is the left-hand argument. The "second way" might work but only by accident.

It seems like you are checking if some string matches some item in a list. In that case you probably should use list_contains() instead of 'in'. Something like:
Code:
list_contains($publisher, ',', '^(Archive of Our Own|FanFiction.net)$', 1, '')
I will look at whether a "in_list" operator makes sense given everything else that is going on inside the interpreter.
chaley is offline   Reply With Quote
Old 03-31-2021, 09:59 PM   #5
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,553
Karma: 61170925
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
I had assigned publisher = $publisher;

Also, what is the name used for these things used to avoid typing the same thing over and over again? e.g.

Code:
	status = $#fanficstatus;
	publisher = $publisher;
	ids = $identifiers;
	u = select(ids, 'url');
 	a = select(ids, 'ao3');
	f = select(ids, 'ffnet');
ownedbycats is offline   Reply With Quote
Advert
Old 04-01-2021, 06:53 AM   #6
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,733
Karma: 6690881
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
I had assigned publisher = $publisher;
I should have noticed that.
Quote:
Also, what is the name used for these things used to avoid typing the same thing over and over again? e.g.

Code:
	status = $#fanficstatus;
	publisher = $publisher;
	ids = $identifiers;
	u = select(ids, 'url');
 	a = select(ids, 'ao3');
	f = select(ids, 'ffnet');
I don't think the "technique" of assigning to local variables to save typing (and usually processing time) has a name. If it does then I don't know it.
chaley is offline   Reply With Quote
Old 04-01-2021, 06:57 AM   #7
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,553
Karma: 61170925
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
"local variables" would probably work well for this.
ownedbycats is offline   Reply With Quote
Old 04-01-2021, 08:30 AM   #8
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 20,550
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Grace Hopper would have called it: WORKING STORAGE

BR
BetterRed is offline   Reply With Quote
Old 04-01-2021, 03:40 PM   #9
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,553
Karma: 61170925
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Question:

Quote:
strcat(a [, b]*) – can take any number of arguments. Returns a string formed by concatenating all the arguments.
What is B used for? In the templates I have that use it, it's just null ''s.
ownedbycats is offline   Reply With Quote
Old 04-01-2021, 04:01 PM   #10
PeterT
Grand Sorcerer
PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.
 
PeterT's Avatar
 
Posts: 12,155
Karma: 73448616
Join Date: Nov 2007
Location: Toronto
Device: Nexus 7, Clara, Touch, Tolino EPOS
Quote:
Originally Posted by ownedbycats View Post
Question:



What is B used for? In the templates I have that use it, it's just null ''s.
I think you code strcat(a), or strcat (a,b) or strcat (a,b,c) adfinitum. All the arguments will be concatenated together.

Sent from my Pixel 4a using Tapatalk
PeterT is offline   Reply With Quote
Old 04-01-2021, 04:19 PM   #11
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,733
Karma: 6690881
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Question:
What is B used for? In the templates I have that use it, it's just null ''s.
I am probably giving you more than you want to know.

That notation describes the "form" of valid calls of the function. It uses 'placeholders' to distinguish between different values. The notation "[, something]" says that the ", something" is optional: zero or one occurrence of what is between the brackets. The notation "[, something]*" says that it is optional but you can have zero to "a lot" of occurrences. Often "somethings" with the same name are the same thing, while "somethings" with different names are not necessarily the same thing.

The notation is an approximation of a formal grammar. I tend to use approximations of EBNF grammars. In this formal system, things that are literal would be in quotes. In that case, what you referenced should be formally written
Code:
'strcat' '(' expression [ ',' expression ]* ')'
where the word 'expression' refers to another grammar element describing what it can be. I often use approximations because I am lazy.

This template language grammar is intended to be formal. I think it is correct but I haven't put it through a grammar verifier to be sure.

Taking all the above together, "strcat(a, [, b]*)" says that the literal 'strcat' is followed by:
  • a literal '('
  • a value, whatever that is. I used 'a' for 'expression'
  • a sequence of zero or more
    • a literal comma
    • a value. I used 'b' to say it need not be the same as 'a'.
  • a literal ');
chaley is offline   Reply With Quote
Old 04-02-2021, 04:11 PM   #12
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,553
Karma: 61170925
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Just curious: is the term "composite column" used anywhere in the Calibre UI? In the column dropdown itself, it's "columns built from other columns."
ownedbycats is offline   Reply With Quote
Old 04-02-2021, 04:17 PM   #13
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,733
Karma: 6690881
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Just curious: is the term "composite column" used anywhere in the Calibre UI? In the column dropdown itself, it's "columns built from other columns."
The term is used in a few places in tool tips. It is used frequently in the template language documentation. And FWIW, 'composite' is the internal datatype of these columns.
chaley is offline   Reply With Quote
Old 04-02-2021, 05:56 PM   #14
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,553
Karma: 61170925
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Quote:
Originally Posted by chaley View Post
And FWIW, 'composite' is the internal datatype of these columns.
I saw that in the custom_columns table of the database.
ownedbycats is offline   Reply With Quote
Old 04-03-2021, 04:57 AM   #15
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,553
Karma: 61170925
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
When using a template in Action Chains to set a boolean column, should I use "Yes/No" or "True/False"?
ownedbycats is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Library Management: various questions not worth their own thread ownedbycats Library Management 130 04-13-2024 10:02 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


All times are GMT -4. The time now is 03:46 AM.


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