1

I have the following code:

PopupMenu[Dynamic[choose], {al, bl, cl}]

and

vin1 = Dynamic[choose]

then, I would like to use such value in a conditional expression If:

If[vin1==al, 3 x + 2, 6 y]

But only vin1 is automatically updated. If doesn't work. How can I solve this?

Gae P
  • 637
  • 3
  • 11
  • Have you seen PopupMenu documentation? Where are you stuck? Do you wan't to run If manually later or automatically? – Kuba Dec 10 '18 at 14:34
  • I set PopupMenu[Dynamic[choose], {al, bl, cl}] and then vin1 = Dynamic[choose]. Furthermore If[vin1 == al, al + bl, cl + bl]. But If doesn't work. – Gae P Dec 10 '18 at 14:45
  • I see, if you manually evaluate vin1 = choose it works. If you want everything to be connected in some kind of gui then you need to explain what do you expect and when. But for Shift+Enter vin1=choose is enough. – Kuba Dec 10 '18 at 14:49
  • I have edited my code. – Gae P Dec 10 '18 at 15:06
  • So can you remove the Dynamic I told you or? – Kuba Dec 10 '18 at 20:54
  • Is this the answer or is there something more that is missing? https://mathematica.stackexchange.com/q/5817/5478 – Kuba Dec 11 '18 at 07:22
  • Solved: I set "al" instead of al, as well as for bl and cl, in the definition of PopupMenu and in If – Gae P Dec 11 '18 at 11:21
  • I don't think so: Dynamic["al"] == "al" – Kuba Dec 11 '18 at 11:27
  • PopupMenu[Dynamic[choose],{"al","bl","cl"} and then If[chhose== "al", 3 x + 2, 6 y] – Gae P Dec 11 '18 at 12:03
  • So you did remove Dynamic, great, btw, use === to compare arbitrary expressions. – Kuba Dec 11 '18 at 12:09

0 Answers0