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 03-23-2013, 08:29 AM   #1
Philantrop
Addict
Philantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beauty
 
Philantrop's Avatar
 
Posts: 296
Karma: 32153
Join Date: Dec 2008
Device: Kindles (e-ink)
Custom yes/no column built from long text column

I have a custom column "foo" of type "Long text, like comments, not shown in the tag browser" which either contains nothing at all or some text.

I'd like to have a simple "Yes/No" column "bar" that, in the library view, shows if "foo" contains anything.

So I added said "Yes/No" column of type "Column built from other columns" and used this template:

program: test(select(field('#annotations'),'.*'),'Yes ','No')

Unfortunately, this function always returns "No". Even when replacing the '.*' with 'e' (because I had prepared "foo"'s content to contain it), it still returned "No".

I've experimented with just using test() but whatever I tried, it simply either returned "Yes" or "No" for *all* entries, regardless of "foo"'s actual content.

Can someone please lend me a hand here? :)
Philantrop is offline   Reply With Quote
Old 03-23-2013, 11:17 AM   #2
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 30,441
Karma: 58055868
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by Philantrop View Post
I have a custom column "foo" of type "Long text, like comments, not shown in the tag browser" which either contains nothing at all or some text.

I'd like to have a simple "Yes/No" column "bar" that, in the library view, shows if "foo" contains anything.

So I added said "Yes/No" column of type "Column built from other columns" and used this template:

program: test(select(field('#annotations'),'.*'),'Yes ','No')

Unfortunately, this function always returns "No". Even when replacing the '.*' with 'e' (because I had prepared "foo"'s content to contain it), it still returned "No".

I've experimented with just using test() but whatever I tried, it simply either returned "Yes" or "No" for *all* entries, regardless of "foo"'s actual content.

Can someone please lend me a hand here?
Have you tried to flip the logic (Not an empty string. those are 2 ' not a double quote)?
Code:
program: test(select(field('#annotations'),''),'No','Yes')
theducks is offline   Reply With Quote
Advert
Old 03-23-2013, 11:24 AM   #3
Philantrop
Addict
Philantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beauty
 
Philantrop's Avatar
 
Posts: 296
Karma: 32153
Join Date: Dec 2008
Device: Kindles (e-ink)
Quote:
Originally Posted by theducks View Post
Have you tried to flip the logic (Not an empty string. those are 2 ' not a double quote)?
Code:
program: test(select(field('#annotations'),''),'No','Yes')
Yes, indeed, I've tried that, too (and just did again with 0.9.24 just to make sure), and that only serves to invert the display (before, everything was "No", now everything is "Yes") but doesn't fix the issue.
Philantrop is offline   Reply With Quote
Old 03-23-2013, 11:34 AM   #4
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 30,441
Karma: 58055868
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by Philantrop View Post
Yes, indeed, I've tried that, too (and just did again with 0.9.24 just to make sure), and that only serves to invert the display (before, everything was "No", now everything is "Yes") but doesn't fix the issue.
I am not that good with program mode (OK, I am pretty lousy ). Inverting the logic (not foo:true) has worked in other places, which is why I tossed it into the pot.
chaley will be around pretty soon and probably point to the error of our ways
theducks is offline   Reply With Quote
Old 03-23-2013, 07:56 PM   #5
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: 12,026
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Why are you using field ('#annotations') instead of field ('#foo')?
chaley is offline   Reply With Quote
Advert
Old 03-23-2013, 08:21 PM   #6
Philantrop
Addict
Philantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beauty
 
Philantrop's Avatar
 
Posts: 296
Karma: 32153
Join Date: Dec 2008
Device: Kindles (e-ink)
Quote:
Originally Posted by chaley View Post
Why are you using field ('#annotations') instead of field ('#foo')?
Because that's the field's actual name which I forgot to replace. foo=annotations.
Philantrop is offline   Reply With Quote
Old 03-23-2013, 08:28 PM   #7
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: 12,026
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
You almost certainly don't want the function select, which operates on lists of colon separated items. You probably want the function contains, which operates on plain text. The regexp for contains would be something like . (a period), testing if the field contains at least one character.
chaley is offline   Reply With Quote
Old 03-23-2013, 08:44 PM   #8
Philantrop
Addict
Philantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beautyPhilantrop does all things with Zen-like beauty
 
Philantrop's Avatar
 
Posts: 296
Karma: 32153
Join Date: Dec 2008
Device: Kindles (e-ink)
Quote:
Originally Posted by chaley View Post
You almost certainly don't want the function select, which operates on lists of colon separated items. You probably want the function contains, which operates on plain text. The regexp for contains would be something like . (a period), testing if the field contains at least one character.
Thank you, that was exactly the nudge into the right direction I needed. :-)

So, the solution to my problem as initially described is rather simple:

program: contains(field('#foo'),'.','Yes','No')
Philantrop is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to move value(s) of tag column to a custom made column zoorakhan Library Management 0 12-08-2012 04:53 AM
custom date column from two state column Dopedangel Library Management 7 01-03-2012 09:20 AM
No search/replace on custom long text column? CWatkinsNash Library Management 2 06-20-2011 06:57 PM
Converting text for a datetime custom column kiwidude Development 2 02-26-2011 11:47 AM
Custom text column with no HTML mfaine Calibre 2 01-07-2011 02:12 PM


All times are GMT -4. The time now is 10:00 AM.


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