![]() |
#301 | |
Grumpy old git
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,386
Karma: 3933793
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
![]() A variable is a container, not an alias. You set or change the contents of a variable by assigning to it. A copy is made of the result of computing the expression on the right-hand side of the '=' then then stored in the variable named on the left-hand side of the '='. The right-hand expression is evaluated before assignment so assigning to a variable doesn't affect the result of the expression. And vice versa, you can change anything that was used in a previous expression without changing what was stored in the variable. Examples: Code:
x = 5; # x contains the value 5. y = x + 1; # y contains 6 (5 + 1). x still contains 5. x = x + 10 # x contains 15 (5 + 10). y still contains 6. y = x + 1; # y contains 16 (15 + 1). x still contains 15. y = (x + y) * 2; # y contains 62 ((15 + 16) * 2). x still contains 15. y = x; # y contains 15. x still contains 15. y = y + 1 # y contains 16. x still contains 15. |
|
![]() |
![]() |
![]() |
#302 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,036
Karma: 17478704
Join Date: Oct 2018
Location: Canada
Device: Kobo Aura HD (retired), Kobo Libra H2O
|
Thanks.
![]() Some stuff in the PyQt6 migration thread made me wonder: can template detect whether light or dark mode is in use? |
![]() |
![]() |
![]() |
#303 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 741
Karma: 211826
Join Date: Aug 2015
Device: Kindle
|
You can do it with a custom template function.
Code:
def evaluate(self, formatter, kwargs, mi, locals): from qt.core import QApplication if QApplication.instance().is_dark_theme: return 1 else: return '' arg count: -1 Code:
program: is_dark_theme() Last edited by capink; 01-25-2022 at 04:34 PM. |
![]() |
![]() |
![]() |
#304 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,036
Karma: 17478704
Join Date: Oct 2018
Location: Canada
Device: Kobo Aura HD (retired), Kobo Libra H2O
|
Thanks.
![]() |
![]() |
![]() |
![]() |
#305 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,036
Karma: 17478704
Join Date: Oct 2018
Location: Canada
Device: Kobo Aura HD (retired), Kobo Libra H2O
|
Is there any type of "goto" option in a template? e.g. if a book matches a certain check, then skip the rest of the if-tree and then go to the next one?
Last edited by ownedbycats; 01-26-2022 at 10:34 PM. |
![]() |
![]() |
![]() |
#306 | |
Grumpy old git
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,386
Karma: 3933793
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
The language doesn't support goto. It does support continue, break, and return. |
|
![]() |
![]() |
![]() |
#307 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,036
Karma: 17478704
Join Date: Oct 2018
Location: Canada
Device: Kobo Aura HD (retired), Kobo Libra H2O
|
Yeah, I meant nested ifs. Probably a nested if would work just as well.
|
![]() |
![]() |
![]() |
#308 |
Grumpy old git
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,386
Karma: 3933793
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
|
![]() |
![]() |
![]() |
#309 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,036
Karma: 17478704
Join Date: Oct 2018
Location: Canada
Device: Kobo Aura HD (retired), Kobo Libra H2O
|
If you mean the nested stored template thing, it's working on source.
![]() |
![]() |
![]() |
![]() |
#310 |
Grumpy old git
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,386
Karma: 3933793
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
|
![]() |
![]() |
![]() |
#311 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,036
Karma: 17478704
Join Date: Oct 2018
Location: Canada
Device: Kobo Aura HD (retired), Kobo Libra H2O
|
My addition was mostly just about how it only affected new stored templates. For example, I'd already had a nested template, fanfic_unreadchaps(). Duplicating it into fanfic_unreadchaps2() and swapping it in broke the nesting. Putting it back unbroke it. Just found that very strange.
|
![]() |
![]() |
![]() |
#312 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,036
Karma: 17478704
Join Date: Oct 2018
Location: Canada
Device: Kobo Aura HD (retired), Kobo Libra H2O
|
Last edited by ownedbycats; 01-28-2022 at 01:52 AM. |
![]() |
![]() |
![]() |
#313 |
Grumpy old git
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,386
Karma: 3933793
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
|
![]() |
![]() |
![]() |
#314 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,036
Karma: 17478704
Join Date: Oct 2018
Location: Canada
Device: Kobo Aura HD (retired), Kobo Libra H2O
|
Code:
if select(ids, 'url') then if '(Archive of Our Own|Fanfiction.net)' in $publisher && '(Completed|Abandoned|Oneshot|Incomplete)' in status then "metadata.png" elif !select(ids, 'ao3') && $publisher == 'Archive of Our Own' && status == 'In-Progress' then 'metadata.png' elif !select(ids, 'ffnet') && $publisher == 'FanFiction.net' && status == 'In-Progress' then "metadata.png" fi fi EDIT: Another question: Did I somehow accidentally turn it into last_non_empty? Last edited by ownedbycats; 01-29-2022 at 04:19 AM. |
![]() |
![]() |
![]() |
#315 | ||
Grumpy old git
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,386
Karma: 3933793
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Quote:
Code:
for x in $tags:'aa' rof |
||
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
A few questions... (template language, mainly) | Clem2605 | Library Management | 2 | 12-30-2020 03:25 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 |
[Old Thread] Save Template not working | TGinAZ | Calibre | 7 | 01-18-2012 01:03 AM |
Thread management questions | meme | Feedback | 6 | 01-31-2011 05:07 PM |