Hello! I have a dropdown menu with a set of pronouns {formmenu: name=Who?; default=they; he; she}, and I would like to insert "them", "his", or "her's" based on my selection in another paragraph in the snippet. What would be the best way to write this? Thanks in advance!
Hi @log62000,
Another great question as I've come to expect from you
One way to do it could be with keyed lists:
{pronounlist=["masc"=["he", "him", "his"], "femm"=["she", "her", "her"], "plur"=["they", "them", "their"]]}
{formmenu: name=pronoun; values={=keys(pronounlist)}}
{=pronounlist[pronoun][1]}
{=pronounlist[pronoun][2]}
{=pronounlist[pronoun][3]}
The number in square brackets references which one of the three sub-list items is being recalled from the list being chosen.
So:
-
pronounlist
is the main keyed list. It is a "list of lists" and contains "masc", "femm" and "plur" together with their respective values. - I've created a
{formmenu}
labeledpronoun
. For its options, I'm using the keys ("masc", "femm" and "plur") from the keyed list calledpronounlist
- Now,
pronoun
is a variable that I'm using in the last three lines. I'm telling Text Blaze to look inside the keyed list of lists (called "pronounlist") for the value corresponding to what's inside "pronoun", and then give me the first, second or third value corresponding to that key. That's what the number in the square brackets does.
It's quite a bit to wrap your head around at first, but it gets easier once you understand the concept
You can read more about lists here:
And of course, I'm happy to answer any other questions you have
Ah, thank you so much, Cedric!! This is brilliant!
1 Like