Re: about the use of button
- To: mathgroup at smc.vnet.net
- Subject: [mg115253] Re: about the use of button
- From: "W. Craig Carter" <ccarter at mit.edu>
- Date: Wed, 5 Jan 2011 05:47:13 -0500 (EST)
Hello Bobby, This appears to be one of those cases where the "equals sign" got turned into two "equals signs" by the email client, the first two lines are single "==" Craig On 4 Jan, 2011, at 4:29 PM, DrMajorBob wrote: > Clicking the button gives an error message: > > carWeight == tareWeight; > personNumber == 0; > > Row[{Button["A person enters", {carWeight +== 60, personNumber++}], > Dynamic[{carWeight, personNumber}]}] > > AddTo::rvalue: carWeight is not a variable with a value, so its value cannot be changed. >> > > Increment::rvalue: personNumber is not a variable with a value, so its value cannot be changed. >> > > Bobby > > On Tue, 04 Jan 2011 03:26:40 -0600, W. Craig Carter <ccarter at mit.edu> wrote: > >> Hello Yang, >> Try this: >> >> ---- >> >> carWeight == tareWeight; >> personNumber == 0; >> >> Row[{Button["A person enters", {carWeight +== 60, personNumber++}], >> Dynamic[{carWeight, personNumber}]}] >> >> ----- >> >> You must avoid underscores "_" in variable names. It is a good habit to use an lower case letter to begin each variable name. Notice that Dynamic sits outside the button--that is the only place you need to see the current (i.e., dynamic) values. >> >> Craig >> >> >> On 28 Dec, 2010, at 6:51 AM, yang wrote: >> >>> Button["A person enters", >>> {Dynamic[car_weight+==60],Dynamic[person_number++}]] >> >> > > > -- > DrMajorBob at yahoo.com