![]() |
#226 | ||
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,449
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
If you want to use a regex then you should use the 'in' operator. Because you want it negated, use Code:
! ('^(In-Progress|Abandoned)$' in $#fanficstatus) Code:
($#fanficstatus != 'Abandoned' && $#fanficstatus != 'In-Progress') Code:
! ($#fanficstatus == 'Abandoned' || $#fanficstatus == 'In-Progress') Quote:
Code:
! ('^Documentation & Manuals$' inlist $#vls) I wonder if you shouldn't sign up to an Intro to Computer Science course. ![]() Last edited by chaley; 12-20-2021 at 10:34 AM. Reason: Change 'not' to the operator ! |
||
![]() |
![]() |
![]() |
#227 |
Connoisseur
![]() Posts: 93
Karma: 10
Join Date: Jun 2011
Location: Albany NY
Device: Moonreader+
|
Could someone please tell me how to get 2 decimal places
program: ($$#minutes / 60) when I try program: ($$#minutes / 60){0:5.2f} or program: {0:.2f}.format($$#minutes / 60) I get a template error Last edited by kevn57; 12-20-2021 at 06:48 AM. |
![]() |
![]() |
Advert | |
|
![]() |
#228 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,449
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Use the format_number() function. Something like Code:
program: format_number($$#minutes / 60, '5.2f') |
|
![]() |
![]() |
![]() |
#229 |
Connoisseur
![]() Posts: 93
Karma: 10
Join Date: Jun 2011
Location: Albany NY
Device: Moonreader+
|
Thanks chaley, I kept trying to mix calibre and python help pages, I never would have come up with that and it works perfectly.
|
![]() |
![]() |
![]() |
#230 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,449
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
|
|
![]() |
![]() |
Advert | |
|
![]() |
#231 |
Connoisseur
![]() Posts: 93
Karma: 10
Join Date: Jun 2011
Location: Albany NY
Device: Moonreader+
|
Thank you again, before I posted I did look at the Function reference that's where I came up with the {0:5.2f} part. In the help details it says " See the template language and Python documentation for more examples." So I started searching for python formatting help. That's where I came up with the {0:.2f}.format.
Looking back at the doc. now it makes a lot more sense. |
![]() |
![]() |
![]() |
#232 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,012
Karma: 75555555
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Is there any functional difference between
Code:
check_yes_no(field('#bool'), '', '', '1') Code:
check_yes_no(field('#bool'), 0, 0, 1) |
![]() |
![]() |
![]() |
#233 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,012
Karma: 75555555
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Also, a question regarding doing math in mixed-use composite columns:
I have a composite column, #chapters, which pulls from integer #chaptercount and provides formatted output. One of those is showing how many chapters of a fanfic I've read (pulled from the Kobo bookmarks column). Another of the outputs is "Not Set" if I haven't set a #chaptercount. I have an action in one of my action chains that checks the #chapters column to see if there's unread chapter and then changes the #percentread from 100 => 98 if so. If it matters, #chapters is set to sort by text. Code:
program: f = re($#chapters, '(.*)/.*', '\1'); s = re($#chapters, '.*/(.*)', '\1'); if and( $$#fanficcat, check_yes_no('#onkobo', '', 1, 1), $$#percentread ==#100, (s - f) ==# 1 ) then '98' else $$#percentread fi This fails with "not set" books. Template tester says could not convert string to float: 'Not Set' Which then breaks the chain when running on books with unset chaptercounts -- I'm guessing from trying to do the math. I tried adding a $#chapters != 'Not Set', to the checks, but that didn't work. Any idea what I missed? EDIT: I think I figured it out. I should've set the 'not set' check as a separate check first. Then if it passed make another if with the other checks. Something like this (I probably messed up the indents.) Code:
program: f = re($#chapters, '(.*)/.*', '\1'); s = re($#chapters, '.*/(.*)', '\1'); if $#chapters != 'Not Set' then if and( $$#fanficcat, check_yes_no('#onkobo', '', 1, 1), $$#percentread ==#100, (s - f) ==# 1 ) then '98' else $$#percentread fi fi Last edited by ownedbycats; 12-20-2021 at 10:19 AM. |
![]() |
![]() |
![]() |
#234 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,449
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Code:
check_yes_no('#bool', '', '', '1') Code:
check_yes_no(strcat('#', 'bool'), '', '', '1') But to make things a bit more confusing the check_yes_no() function checks if the parameter is a 1 (or '1'). Anything else is assumed to be 0. Because of this peculiarity the following three are equivalent: Code:
check_yes_no('#mybool', 0, 0, 1) check_yes_no('#mybool', '', '', 1) check_yes_no('#mybool', 'mybad', 'ohno', '1') |
|
![]() |
![]() |
![]() |
#235 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,449
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
![]() What you are seeing is the difference between evaluation of parameters for a function and shortcutting for operators. For a function, all of the parameters are evaluated then passed to the function, in this case 'and()'. Because they are all evaluated the test $#chapters != 'Not Set', doesn't stop evaluation of the other parameters. However, if using shortcutting then evaluation stops once the result cannot change. For example Code:
if '' && 2 * 3 then Using shortcutting we can fix your condition in one of two ways: Code:
if $#chapters != 'Not Set' && and( $$#fanficcat, check_yes_no('#onkobo', '', 1, 1), $$#percentread ==#100, (s - f) ==# 1 ) then ... Code:
if $#chapters != 'Not Set' && $$#fanficcat && check_yes_no('#onkobo', '', 1, 1) && $$#percentread ==#100 && (s - f) ==# 1 then ... |
|
![]() |
![]() |
![]() |
#236 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,449
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
@ownedbycats: BTW: yet again I led you astray in this reply.
![]() I typed the word 'not' instead of the operator '!'. It worked only because the parentheses turned the 'not' into a function call. The operator has much better performance than the function. I fixed the post. Last edited by chaley; 12-20-2021 at 10:49 AM. Reason: Make it clear whom I am talking to. |
![]() |
![]() |
![]() |
#237 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,449
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Code:
program: if $#chapters != 'Not Set' then f = re($#chapters, '(.*)/.*', '\1'); s = re($#chapters, '.*/(.*)', '\1'); if and( $$#fanficcat, check_yes_no('#onkobo', '', 1, 1), $$#percentread ==#100, (s - f) ==# 1 ) then '98' else $$#percentread fi # IS SOMETHING SUPPOSED TO GO HERE? # In the original template this would return $$#percentread # The new code returns the empty string fi |
|
![]() |
![]() |
![]() |
#238 |
Member
![]() Posts: 12
Karma: 10
Join Date: Dec 2020
Device: Kobo Libra H2O
|
Hello.
Is there anyway to "read" the filetype being sent to the device? I wanted to do a conditional that would place epubs, kepubs and pdfs on different places in my device. Example: book.epub -> .books/{authors}-{series:||-}{series_index:||-}{title} book.kepub -> books/{authors}/{title} book.pdf -> pdf/{title} Thanks in advance |
![]() |
![]() |
![]() |
#239 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,012
Karma: 75555555
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
What I do is have a #kobopath column that handles the different preferences. then I plug that into the path itself.
You can either make a composite or use Action Chains to generate it in a standard text column. If you use the latter you'll want to use {#kobopath:re(_,/)} instead of just {kobopath} to keep your slashes working. |
![]() |
![]() |
![]() |
#240 | |
Member
![]() Posts: 12
Karma: 10
Join Date: Dec 2020
Device: Kobo Libra H2O
|
Quote:
I might just be better of using kepubs exclusively and pdfs where appropriate. |
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Library Management: various questions not worth their own thread | ownedbycats | Library Management | 218 | 07-11-2025 07:34 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 |