1
$\begingroup$

This may be a routine answer that I have overlooked, but I am stumped...

If I want to write a function using ChoiceDialog, how can I use what ChoiceDialog returns (true or false) to either set a variable to True or False(or perhaps to either create a global variable or not create a global variable which would effectively do the same thing for my purposes). Is it possible to use the returned True or False within the same function to create this global variable?

$\endgroup$
0

1 Answer 1

1
$\begingroup$

Since ChoiceDialog returns a value, as opposed to just printing something, you are free to use it as the right hand side of a variable assignment. Here is a simple example of a function that calls ChoiceDialog and assigns the True or False to a local variable.

choice[] := Module[{val}, 
   val = ChoiceDialog["choose"]; 
   If[val, a, b] 
] 

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.