Sign up ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

According to the help:


Is it possible to make the button execute two actions?

share|improve this question

3 Answers 3

up vote 11 down vote accepted

Look at CompoundExpression :

Button["Click Here", Print[10!]; Print[11!]]
 "Click Here"  

when clicked it performs two actions

share|improve this answer
Thanks for it, I didn't know about the existance of compoundEpression. –  Voyska Jul 6 '12 at 11:04

Use CompoundExpression, which will be more familiar in the form of the ; operator (which many wouldn't recognize as an operator at all).

This works anywhere where a single command seems to be called for in a syntax description. CompoundExpression returns the result of the last operation or Null if there isn't any.

share|improve this answer
Thanks for the answer. –  Voyska Jul 6 '12 at 11:05

Module[] while a bit longer seems to work too:

Button["Click Here", Module[{}, {Print[10!], Print[11!]}]]
share|improve this answer
Module is unecessary here: you simply use List to substitute CompoundExpression. –  István Zachar Jul 6 '12 at 12:39
@IstvánZachar - List works great, I just thought that Module might provide more flexibility to do more things than Print. The OP asked "Is it possible to make the button execute two actions?" "...two actions?" covers lots of possible ground. –  Jagra Jul 6 '12 at 13:59
@Jagra Please try Button["Click Here", {Print[10!], Print[11!]}] and Button["Click Here", Print[10!]; Print[11!]]. Module does nothing in this case. –  Alexey Popkov Jul 6 '12 at 14:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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