05-05-2014, 12:20 PM | #16 | |
Grand Sorcerer
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
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".') Last edited by chaley; 05-05-2014 at 12:24 PM. |
|
05-09-2014, 03:53 PM | #17 |
frumious Bandersnatch
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. |
05-09-2014, 06:25 PM | #18 | |
Ex-Helpdesk Junkie
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:
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") |
|
05-10-2014, 06:15 AM | #19 |
Grand Sorcerer
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
|
05-10-2014, 06:17 PM | #20 |
Connoisseur
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. |
05-10-2014, 06:20 PM | #21 |
null operator (he/him)
Posts: 20,575
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
|
05-11-2014, 10:25 AM | #22 | |
Connoisseur
Posts: 65
Karma: 400010
Join Date: Mar 2013
Location: London
Device: Nook STG, PW2
|
Quote:
|
|
05-11-2014, 08:18 PM | #23 |
null operator (he/him)
Posts: 20,575
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
|
|
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 |