Dynamically combining variables into a sentence

Hi team!

Is there a way to dynamically populate a varying number of variables into a sentence? I have an example snippet below with the desired outputs. The main trouble I'm running into is letting Textblaze know when to include and/commas based on the number of variables.

Shopping List: {formtext: name=Shopping List}

Apple: {formtoggle: name=Apple; default=no}{endformtoggle}
Orange: {formtoggle: name=Orange; default=no}{endformtoggle}
Lemon: {formtoggle: name=Lemon; default=no}{endformtoggle}

Define Shopping List
{if: `Shopping List`=="1"}{elseif: `Shopping List`=="2"}{Apple="Yes"}{elseif: `Shopping List`=="3"}{Apple="Yes"}{Orange="Yes"}{elseif: `Shopping List`=="4"}{Apple="Yes"}{Lemon="Yes"}{elseif: `Shopping List`=="5"}{Apple="Yes"}{Lemon="Yes"}{Orange="Yes"}{endif}

Desired Outputs
Shopping list 1= ""
Shopping list 2= Apple
Shopping list 3= Apple and Orange
Shopping list 4=Apple and Lemon
Shopping list 5=Apple, Lemon, and Orange

Hi @Abby_Buccino

Does this work for you?

Shopping List: {formmenu: name=Shopping List; Apple; Orange; Lemon; multiple=yes}

Ingredients: {=join(`Shopping List`, "BLAZE_AND")}

This is a step in the right direction, but because of how I'm defining the variables, I can't use the multiple select. The variables either contain data or are "". This is causing the function to always populate a space for the variable. For example: If only Apple and Lemon contain data, but Orange is "", it still shows:

Apple, and Lemon.

If nothing is populated it shows: ,and

To further explain, I always have a list with the same variables that may or may not contain data:

{Ingredients=join(List, "BLAZE_AND")}

I figured it out :slight_smile:

join(filter(`List`, x->x<>""), "BLAZE_AND")