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 08-19-2012, 03:15 PM   #1
jcallaway
Junior Member
jcallaway began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Aug 2012
Device: Nexus 7
Syntax for nesting functions in program mode

Hi, I'm trying to create a Save to Disk template that will modify author_sort in two ways:
1) Return only the first author
2) Remove any periods (so that they aren't converted to underscores).

For example, given a book with authors Philip K. Dick & Roger Zelazny I want to return Dick, Philip K

I have each modification working on it's own in single-function mode:
1) {author_sort:re(\.,)} returns Dick, Philip K & Zelazny, Roger
2) {author_sort:sublist(0,1,&)} returns Dick, Philip K_


But I'm having trouble with the syntax for nesting the re() and sublist() functions to make them work together. I've tried a lot of variations along the lines of:
{author_sort:'sublist(re($,\.,),0,1,&)'} or {author_sort:'re(sublist($,0,1,&),\.,)'}

But I always get Invalid Input or Incorrect Number of Arguments errors. I'm not very familiar with the syntax, so I know that I don't really know when I need to escape characters or add whitespace, whether the nesting order matters, etc. Any ideas what I'm doing wrong?
jcallaway is offline   Reply With Quote
Old 08-19-2012, 05:31 PM   #2
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,734
Karma: 6690881
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
You must choose one of single-function mode, template program mode, or general program mode. The syntax is different for each of the three.

For example, your template
Code:
{author_sort:'sublist(re($,\.,),0,1,&)'} or {author_sort:'re(sublist($,0,1,&),\.,)'}
is in template program mode where all string constants must be quoted. It should be written something like
Code:
{author_sort:'sublist(re($, '\.', ''),0,1,'&')'}
or
Code:
{author_sort:'re(sublist($,0,1,'&'), '\.', '')'}

Last edited by chaley; 08-20-2012 at 03:16 AM.
chaley is offline   Reply With Quote
Advert
Old 08-20-2012, 02:26 AM   #3
jcallaway
Junior Member
jcallaway began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Aug 2012
Device: Nexus 7
That worked perfectly! That's a lot for the quick info.
jcallaway is offline   Reply With Quote
Reply

Tags
nesting, strip, template


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
syntax tags MMAC Library Management 1 02-29-2012 03:51 PM
Help with plugboard syntax, please Ptarmigan Library Management 3 02-15-2012 05:44 AM
Request Safe mode or recovery mode for Pocket Edge? felixblackcat enTourage eDGe 25 01-08-2012 05:07 PM
Does anyone use "general program mode" template functions? chaley Library Management 0 08-16-2011 11:54 AM
Help with search syntax please. rwelbourn Library Management 3 04-16-2011 02:07 AM


All times are GMT -4. The time now is 11:27 AM.


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