![]() |
#16 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,449
Karma: 8012886
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. |
|
![]() |
![]() |
![]() |
#17 |
frumious Bandersnatch
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,550
Karma: 19500001
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. |
![]() |
![]() |
Advert | |
|
![]() |
#18 | |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 19,421
Karma: 85400180
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") |
|
![]() |
![]() |
![]() |
#19 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,449
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
|
![]() |
![]() |
![]() |
#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. |
![]() |
![]() |
Advert | |
|
![]() |
#21 |
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 21,745
Karma: 30237526
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
|
![]() |
![]() |
![]() |
#22 | |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 65
Karma: 400010
Join Date: Mar 2013
Location: London
Device: Nook STG, PW2
|
Quote:
|
|
![]() |
![]() |
![]() |
#23 |
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 21,745
Karma: 30237526
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
|
![]() |
![]() |
![]() |
|
![]() |
||||
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 |