how to link the chosen elements from the lists

473 views
Skip to first unread message

Petros Efstathiou

unread,
Mar 18, 2017, 10:07:19 AM3/18/17
to mitappinv...@googlegroups.com
hello ! i am trying to make a app about coktails . i made lists with ingredients and now i wanna make a button and when i push this button will link the ingredients (which i have selected from the lists previous) and show the cocktail which is made
for example: listpicker1 elements are vodka, beer, whisky,wine and listpicker2 elements are champagne, liquerus,martini,sangria
and we have a button with the name "MIX" . i want  when i pick ''vodka'' from listpicker1 and ''martini'' from listpicker2 and press the ''MIX'' button , to show me the cocktail ''BLOODY MARY'' in an another screen .
sorry for my english ! if anybody knows plzz help me

Tim Carter

unread,
Mar 18, 2017, 4:45:58 PM3/18/17
to mitappinv...@googlegroups.com
There are probably many easier ways to do this, and a better AI2 programmer than i may come along with a better solution, but this example should give you an idea of what you need to do:




I only used one list for ingredients, and the first and second selections are removed from the second and third listpickers. I didn't include any three ingredient examples. You can use "start value" or a tinydb to transfer the "MIX" output to another screen.


cocktails.aia

Petros Efstathiou

unread,
Mar 18, 2017, 5:02:42 PM3/18/17
to MIT App Inventor Forum
thank you very much !!! i will try this way !! 

Abraham Getzler

unread,
Mar 18, 2017, 10:06:55 PM3/18/17
to MIT App Inventor Forum
How could any app get BLOODY MARY from vodka and martini?
I would expect it to get vodka martini

There is no tomato juice in vodka or martini.

Could you pick a working example?

ABG


Petros Efstathiou

unread,
Mar 19, 2017, 8:17:08 AM3/19/17
to MIT App Inventor Forum
i think the ingredients taken in luck (its only an example)  !! :) 

Abraham Getzler

unread,
Mar 19, 2017, 1:21:30 PM3/19/17
to MIT App Inventor Forum
I'm trying to understand what questions your intended app should answer.

Would I be correct if I guessed that it lets the user choose from lists
of ingredients, as many as he wants, and at each step lists only
the recipes that contain ALL of those ingredients?

Then after a recipe name is chosen from the filtered recipe list, that recipe is
displayed in detail?

By the way, encoding your recipes in list blocks might be okay for  only
a handful of examples, but to grow into a useful and large collection you will need
a way to encode recipes in data file(s) and load them as csv (or JSON) data.

See here for sample data file loading techniques ...

(The files they load are csv tables, but the problems they solve have no relation to yours,
so don't bother reading them past the point where the files are loaded thru a csv conversion block.)

ABG

Petros Efstathiou

unread,
Mar 19, 2017, 2:53:57 PM3/19/17
to MIT App Inventor Forum
Yes that was my thought. Do you think if I want to use more ingredients and recipes I have to use your way ; ( btw what's Abg?) thanks for your advice!

Abraham Getzler

unread,
Mar 19, 2017, 3:43:16 PM3/19/17
to MIT App Inventor Forum
See this doc for how to load a table from a file uploaded to the Media drawer.

The app simulates a quest finding your way from the Big Bang to MIT,
in a dozen steps or so.

If you can divide the universe of cocktail recipes into non-intersecting groups
and subgroups of recipes, you could use the blocks as is, with your own recipe file built to
the same structure as my Universe file.

My initials are
ABG

Petros Efstathiou

unread,
Mar 19, 2017, 4:22:26 PM3/19/17
to MIT App Inventor Forum
Thanks!!! :)

Abraham Getzler

unread,
Mar 20, 2017, 3:52:06 PM3/20/17
to MIT App Inventor Forum
For fun, I coded up the app with a few recipes (some fake),
and put it on the Gallery at

Here's a recipe I forgot to include:

Putin On The Ritz:
 Vodka 
 Ritz Cracker

(Not my invention).
ABG


blocks.png
Capture.PNG
drink_recipes.aia
DrinkRecipes.csv

Petros Efstathiou

unread,
Mar 23, 2017, 7:20:16 AM3/23/17
to MIT App Inventor Forum
Thank you for your help!!!

Abraham Getzler

unread,
Mar 23, 2017, 12:56:40 PM3/23/17
to MIT App Inventor Forum
It occurred to me that I might have solved the wrong problem.

I solved the problem of WHICH RECIPES REQUIRE ALL MY SELECTED INGREDIENTS.

A more useful question would be:
Given a list of recipes, and a list of ingredients in stock versus out of stock,
what are the names of the recipes I can make using only ingredients I have in stock?

Is that closer to your question?

ABG

Reply all
Reply to author
Forward
0 new messages