View Single Post
Old 12-23-2013, 08:57 PM   #368
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
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)
Just say the word and I will add in a few more ifs for multiple two-word sections.

Assuming it IS just the last section, here is the version with support for the multiword section:

Code:
program:
#save stuff before " - "
start=list_item(field('tags'),-2, ' - ');
#save stuff after it
end=list_item(field('tags'),-1, ' - ');
#divides 'end' into two, at '/'
part3=list_item(end,-2,'/');
part4=list_item(end,-1,'/');

part3alt=list_item(part4,-2,' ');
part4=list_item(part4,-1,' ');


#return a value
strcat(
#add first initial
	shorten(start,1,'',0),
#add first separator if first initial not empty
	test(start,' - ',''),
#add second initial
	shorten(part3,1,'',0),
#add second separator if third not empty
	test(part3,'/',''),
#if last section had ' ' not '/', use these two lines instead
##add third initial part 1
	shorten(part3alt,1,'',0),
##if third initial part 1 exists, add ' ' separator
	test(part3alt,' ',''),
#add third initial
	shorten(part4,1,'',0),
)
One-line monster:
Code:
program:start=list_item(field('tags'),-2, ' - ');end=list_item(field('tags'),-1, ' - ');part3=list_item(end,-2,'/');part4=list_item(end,-1,'/');part3alt=list_item(part4,-2,' ');part4=list_item(part4,-1,' ');strcat(shorten(start,1,'',0),test(start,' - ',''),shorten(part3,1,'',0),test(part3,'/',''),shorten(part3alt,1,'',0),test(part3alt,' ',''),shorten(part4,1,'',0),)
eschwartz is offline   Reply With Quote