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 05-05-2014, 12:20 PM   #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,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by davidfor View Post
chaley: I like it. My vote goes for the first version. The second version is a lot more flexible, but I think the first is much simpler to read and understand. With the second I know I would mess up the arguments and spend hours trying to sort out. And if I didn't put them in order, I would miss a range somewhere.

I sort of like the idea of having it as:

Code:
first_matching_compare(v, val1, lt1, val2, lt2,  ..., ltn, elseval)
That reads to me as: val1 if v<lt1, val2 if lt1<=v<lt2, val3 if lt2<=v<lt3 and so on until elseval if v>=ltn. But, I think that would be inconsistent with the other template functions.
You are right, that is inconsistent with all the other similar functions.

I submitted the changes to Kovid (not yet merged) for a "first_matching_cmp" function. I decided to use "cmp" so that it was consistent with the numeric comparision function "cmp" and not confused with strcmp. If there is demand I can also add a first_matching_strcmp, but I don't see many use cases for it.

The inline doc for the new function is
Code:
_('first_matching_cmp(val, cmp1, result1, cmp2, r2, ..., else_result) -- '
            'compares "val < cmpN" in sequence, returning resultN for '
            'the first comparison that succeeds. Returns else_result '
            'if no comparison succeeds. Example: '
            'first_matching_cmp(10,5,"small",10,"middle",15,"large","giant") '
            'returns "middle". The same example with a first value of 16 '
            'returns "giant".')
EDIT: Kovid committed the change to the "master" branch.

Last edited by chaley; 05-05-2014 at 12:24 PM.
chaley is offline   Reply With Quote
Old 05-09-2014, 03:53 PM   #17
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,516
Karma: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
If the comparison is "val < cmpN", the example:

first_matching_cmp(10,5,"small",10,"middle",15,"la rge","giant")

should return "large", not "middle", since 10 < 10 is not true.

(EDIT: what the...? Why does "large" appear as "la rge" in my post? I even typed the whole line, so no weird characters there)

Last edited by Jellby; 05-09-2014 at 03:55 PM.
Jellby is online now   Reply With Quote
Advert
Old 05-09-2014, 06:25 PM   #18
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Quote:
Originally Posted by Jellby View Post
If the comparison is "val < cmpN", the example:

first_matching_cmp(10, 5, "small", 10, "middle", 15, "large", "giant")

should return "large", not "middle", since 10 < 10 is not true.

(EDIT: what the...? Why does "large" appear as "la rge" in my post? I even typed the whole line, so no weird characters there)
Here, I fixed it for you.

The forum software has a weird problem it seems, where a single line of text that is too long without spaces will get randomly broken in the middle. You could also put it in as code, which kinda fits here.

Code:
first_matching_cmp(10,5,"small",10,"middle",15,"large","giant")
eschwartz is offline   Reply With Quote
Old 05-10-2014, 06:15 AM   #19
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,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Jellby View Post
If the comparison is "val < cmpN", the example:

Code:
first_matching_cmp(10,5,"small",10,"middle",15,"large","giant")
should return "large", not "middle", since 10 < 10 is not true.
Fix to documentation submitted to Kovid.
chaley is offline   Reply With Quote
Old 05-10-2014, 06:17 PM   #20
Snow Sciles
Connoisseur
Snow Sciles ought to be getting tired of karma fortunes by now.Snow Sciles ought to be getting tired of karma fortunes by now.Snow Sciles ought to be getting tired of karma fortunes by now.Snow Sciles ought to be getting tired of karma fortunes by now.Snow Sciles ought to be getting tired of karma fortunes by now.Snow Sciles ought to be getting tired of karma fortunes by now.Snow Sciles ought to be getting tired of karma fortunes by now.Snow Sciles ought to be getting tired of karma fortunes by now.Snow Sciles ought to be getting tired of karma fortunes by now.Snow Sciles ought to be getting tired of karma fortunes by now.Snow Sciles ought to be getting tired of karma fortunes by now.
 
Posts: 65
Karma: 400010
Join Date: Mar 2013
Location: London
Device: Nook STG, PW2
I'm going to butt in here and ask, how do you get the word count for a book? Do you add it manually, or is there another way?

I ask because I'm looking to pull info from some epubs and place it into a column, but is this even possible? The cover has linked info about the story, (fandom, word count, tags etc..) that would be useful.
Snow Sciles is offline   Reply With Quote
Advert
Old 05-10-2014, 06:20 PM   #21
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,575
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
@Snow Sciles see - Count Pages Plug In - https://www.mobileread.com/forums/sho...d.php?t=134000

BR
BetterRed is offline   Reply With Quote
Old 05-11-2014, 10:25 AM   #22
Snow Sciles
Connoisseur
Snow Sciles ought to be getting tired of karma fortunes by now.Snow Sciles ought to be getting tired of karma fortunes by now.Snow Sciles ought to be getting tired of karma fortunes by now.Snow Sciles ought to be getting tired of karma fortunes by now.Snow Sciles ought to be getting tired of karma fortunes by now.Snow Sciles ought to be getting tired of karma fortunes by now.Snow Sciles ought to be getting tired of karma fortunes by now.Snow Sciles ought to be getting tired of karma fortunes by now.Snow Sciles ought to be getting tired of karma fortunes by now.Snow Sciles ought to be getting tired of karma fortunes by now.Snow Sciles ought to be getting tired of karma fortunes by now.
 
Posts: 65
Karma: 400010
Join Date: Mar 2013
Location: London
Device: Nook STG, PW2
Quote:
Originally Posted by BetterRed View Post
@Snow Sciles see - Count Pages Plug In - https://www.mobileread.com/forums/sho...d.php?t=134000

BR
Thanks!! I've yet to explore the plugin features.
Snow Sciles is offline   Reply With Quote
Old 05-11-2014, 08:18 PM   #23
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,575
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by Snow Sciles View Post
Thanks!! I've yet to explore the plugin features.
Then I urge you to do so, there's a sticky index in the Plugins sub forum.

BR
BetterRed is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom column returns value based on value of another custom column? calvin-c Calibre 3 09-14-2013 02:24 PM
Custom yes/no column built from long text column Philantrop Library Management 7 03-23-2013 07:44 PM
how to move value(s) of tag column to a custom made column zoorakhan Library Management 0 12-08-2012 03:53 AM
custom column: count number of characters (in book path) miquele Library Management 25 09-21-2012 01:54 PM
custom date column from two state column Dopedangel Library Management 7 01-03-2012 08:20 AM


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


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