That's a great way of doing it. I was trying to think of another, but that's probably the most elegant way at the moment (I thought about trying to put together a "user-defined function" in a table using a Dataset, but I'm on my Mac w/o easy access to a copy of TS). This (or something similar but more generic) might be a good candidate for a new function in 5.2. On Tue, Jun 18, 2013 at 9:23 PM, Sablesword <Sablesword@...> wrote: **
Thanks for the suggestions.
What I ended up doing was to put the optional features into a single variable, keeping track of the number of optional features used and then trimming and adding an "and" as appropriate at the end.
# Harem slavegirl facial features # (work in progress, features still to be refined) ;sgFace # %NoF% starts at max possible number of optional facial features 1,|NoF=4|[sgFace_shape] with _|FFeatures=[sgForehead][sgCheekbones][sgNose][sgLips]| _{If~%NoF%=1?{Left~{Calc~{Length~%FFeatures%}-1},%FFeatures%} and} _{If~%NoF%>1? %FFeatures% and} [sgEyes] eyes.
[...]
;sgNose # Reduce %NoF% by 1 each time nothing selected 10,|NoF-1| 1, an aquiline nose, 1, a small, upturned nose, 1, a sharp nose, 1, a broad nose,
... and the other optional-facial-features groups done likewise.
--- In TableSmith@..., "kuseru" <kuseru@...> wrote:
Set all the options as variables, then use If statements to show those variables if they come up. I.e.
%n%,0 %l%,0 %e%,0 %nose%,normal %lips%,normal %ears%,normal
### somewhere in table for determination
:Nose 1,|n=1||nose=small| 2, #normal (you should of course leave an option blank (in whatever amount you desire for "normal" body parts, this is only a location note)
3,|n=1||nose=large| 4,|n=1||nose=bulbous|
:Lips 1,|l=1||lips=small| 2, #normal 3,|l=1||lips=large|
:Ears 1,|e=1||ears=small| 2, #normal 3,|e=1||ears=large|
#### wherever your output line is {If~%e%=1?%ears%, /}{If~%l%=1?%lips%, /}{If~%n%=1?%nose%, /} and [Eyes] # Note 1: You don't have to make the eyes a variable since you always want them to show up.
# Note 2: You can arrange the output text for additional items any way you want beyond just the size or shape descriptor you choose, i.e. "a %nose% nose, ".
# Note 3: Note the inclusion of a space after the variable (or textual format you choose), but not between If statements, this makes the output workable by placing spaces where needed.
--- In TableSmith@..., "Sablesword" <ErolB1@> wrote:
What's the cleanest, most elegant way to set up a group or set of
groups that outputs a serial list of varying length, so as to properly include the optional commas and final optional "and"?
E.g. "... with x, y, z, and aa." where the "aa" is always present, but
the x, y, and z are all optional, so that the output will sometimes have two or more of the optional elements ("with x, y, and aa") sometimes just one of the optional elements ("with z and aa" - no comma) and sometimes with none of the optional elements ("with aa" - no "and").
Is the most elegant answer to first determine how many optional items
are in the list, and then run a group with the three cases (zero optional item, one optional item, two or more optional items)? Is it to keep track of how many optional items are generated and to toggle the commas and the final "and" based on this? Is there another, better answer?
In particular, I'm trying to set up a "face description" table, where
the eyes are always described at the end, but the various other facial features are only described if they're unusual in some way: Nose mentioned if it's big, small, or otherwise special, but not if it's average; mouth mentioned if it's generous, or thin and bloodless, or permenantly frowning, or otherwise odd, but not if it's normal; a scar mentioned if it's present, but not otherwise; and so on.
[Non-text portions of this message have been removed]
|