Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 03-07-2011, 06:02 PM   #1
theducks
Grand Sorcerer
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: 14,094
Karma: 5468860
Join Date: Aug 2009
Location: The (original) Silicon Valley, USA
Device: Galaxy Tab 2, Astak Pocket Pro, K4NT
Question Complex SaveTo pattern error

I just got around to trying this feature (been doing a pick from 2 patterns)

Code:
{series:switch("","00noseries"/{author_sort[0]}_authors/{authors}/{title}_{id}_{title}-{authors},{series[0]}-series/{series}/{series_index:0>2s}-{title}_{id}_{authors})}
When I save a series I get the second (else) part.
When the series is blank, the attached file (OPF part of the pair. Avoiding copyright issues ) name is generated (no folder path,either)
BTW,I tries without the quotes around 00noseries first.

did I miss something?
TNX

Last edited by theducks; 08-16-2012 at 08:30 PM.
theducks is offline   Reply With Quote
Old 03-08-2011, 04:42 AM   #2
chaley
"chaley", not "charley"
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: 4,919
Karma: 802172
Join Date: Jan 2010
Location: France
Device: Many android devices
Quote:
Originally Posted by theducks View Post
I just got around to trying this feature (been doing a pick from 2 patterns)

Code:
{series:switch("","00noseries"/{author_sort[0]}_authors/{authors}/{title}_{id}_{title}-{authors},{series[0]}-series/{series}/{series_index:0>2s}-{title}_{id}_{authors})}
When I save a series I get the second (else) part.
When the series is blank, the attached file (OPF part of the pair. Avoiding copyright issues ) name is generated (no folder path,either)
BTW,I tries without the quotes around 00noseries first.

did I miss something?
TNX
You missed a lot.

The template language supports three modes: single function, template program, and general program. Your template is using single function syntax, which (unfortunately for your example) does not support quoted strings or non-constant arguments (arguments that require further evaluation). In addition, no mode supports implicit string concatenation, which you are using after "00noseries". Finally, the regular expression "" (in the switch) will look for literal 2 quotes and match anything, which isn't what you want. You would need something like ^$, or "^$" in one of the other two modes.

You could use template program mode and fix all of this, but with something as complex as you have I would instead suggest that you use general program mode. In that mode, the program would be:
Code:
program: 
test(	field('series'), 
	template("{series[0]}-series/{series}/{series_index:0>2s}-{title}_{id}_{authors}"),
	template("00noseries/{author_sort[0]}_authors/{authors}/{title}_{id}_{title}-{authors}")
)
For completeness, note that the although the above program works, it prints some exception messages. The reason is that the second argument to test, the first template line, is evaluated but not used. In that context, {series[0]} is invalid. A cleaner implementation, one with no exceptions, would be:
Code:
program: 
test(	field('series'), 
	strcat(
		substr(field('series'), 0, 1),
		template("-series/{series}/{series_index:0>2s}-{title}_{id}_{authors}")
	),
	template("00noseries/{author_sort[0]}_authors/{authors}/{title}_{id}_{title}-{authors}")
)

Last edited by chaley; 03-08-2011 at 10:56 AM.
chaley is offline   Reply With Quote
Old 03-08-2011, 09:36 AM   #3
theducks
Grand Sorcerer
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: 14,094
Karma: 5468860
Join Date: Aug 2009
Location: The (original) Silicon Valley, USA
Device: Galaxy Tab 2, Astak Pocket Pro, K4NT
Wow!

I can put all that (the last) into a 'save to disk' template?
theducks is offline   Reply With Quote
Old 03-08-2011, 09:48 AM   #4
theducks
Grand Sorcerer
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: 14,094
Karma: 5468860
Join Date: Aug 2009
Location: The (original) Silicon Valley, USA
Device: Galaxy Tab 2, Astak Pocket Pro, K4NT
Thumbs up Works perfectly

Answered my own question by testing

theducks is offline   Reply With Quote
Old 03-08-2011, 10:55 AM   #5
chaley
"chaley", not "charley"
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: 4,919
Karma: 802172
Join Date: Jan 2010
Location: France
Device: Many android devices
Quote:
Originally Posted by theducks View Post
Answered my own question by testing
:
Good. And you are welcome.

Out of curiosity, why do you have the title in the name twice in the "00noseries" template?
chaley is offline   Reply With Quote
Old 03-08-2011, 11:20 AM   #6
theducks
Grand Sorcerer
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: 14,094
Karma: 5468860
Join Date: Aug 2009
Location: The (original) Silicon Valley, USA
Device: Galaxy Tab 2, Astak Pocket Pro, K4NT
Quote:
Originally Posted by chaley View Post
Good. And you are welcome.

Out of curiosity, why do you have the title in the name twice in the "00noseries" template?
GIGO
That was an error I corrected long ago in the actual template (when th underscore used to be a / and failed to correct in my 'Notes log' that I used for the message.
+fixed+
theducks is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sewing pattern for e-readers! strawhatbrat Deals, Freebies, and Resources (No Self-Promotion) 11 12-02-2010 09:23 PM
header removal fails, even though test identifies the pattern hpep Calibre 2 08-09-2010 12:40 PM
Virus pattern match upon connecting Astak Pocket Pro to my computer Xochipilli2012 Astak EZReader 6 03-04-2010 02:24 AM
Literary Pattern Matching kennyc News 5 12-16-2009 03:12 PM
How do I specify TOC pattern? PaulChernoch Calibre 5 10-10-2009 01:18 AM


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


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