View Single Post
Old 10-21-2010, 08:23 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: 5,902
Karma: 1216548
Join Date: Jan 2010
Location: France
Device: Many android devices
Quote:
Originally Posted by Sweetpea View Post
So, something like:

{series_index:switch(00[0-9][0-9], 0000-0099, 01[0-9][0-9], 0100-199, ....} etc...
Unfortunately for this idea, the switch method operates on the value converted to string but before formatting is applied. Because of this, a series index of 1 converts to the string '1', and thus won't match the pattern '00[0-9][0-9]'.

Adding a format operation, such as {series_index:0>4s:switch(....)}, doesn't help. The formatting is applied after the value is determined, which means after the functions have produced a value.

The right solution is to add a function that can do arithmetic on a field. It could look something like 'compute(expression)'. Expression would be a combination of operators, constants, and 'x' to stand for the named field.

This function would permit a general solution, at the cost of requiring 4 composite fields. They would look something like
Code:
#index1_left:{series_index:compute(((x/100)*100)+1)}
#index1_right: {#index1_left:compute(x+99)}
#index2_left:{series_index:compute((((x%100)/10)*10)+1)}
#index2_right:{#index2_left:compute((x+9)}

template: {#genre}/{series:||/}{#index1_left:0>4s||-}{#index1_right:0>4s:||/}{#index2_left:0>4s||-}{#index2_right:0>4s:||/}{title}
I know that you (sweetpea) could work this out, but it doesn't seem likely that many people could figure out how this works, much less build it from scratch. Couple that with low general utility, and it doesn't seem to be worth the trouble of building.
chaley is offline   Reply With Quote