Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Cannot calculate with Dynamic variables
Replies: 1   Last Post: Nov 24, 2012 2:30 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Rolf.Mertig@gmail.com

Posts: 38
Registered: 11/23/05
Re: Cannot calculate with Dynamic variables
Posted: Nov 24, 2012 2:30 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Dear Reinhard,
something like this will work.
However, it is kind of difficult to enter 10 (you have to be fast, or
click back
into the InputField after typing the 1).
So I would suggest to use PopupMenu instead.

Rolf Mertig

DynamicModule[{mark4 = 1/3, mark3 = 0.51, mark2 = 0.68, mark1 = 0.80,
initPtsPartA = {{10, 8, 10, 6}, {10, 5, 10, 5}, {10, 7, 10, 1}},
initPtsStudent, initPtsSchool, initPtsPartSum, numTable, SchoolAPts,
StudentAPts, StudentMinAchieved},
numTable[x_, y_ /; OddQ[y]] := initPtsPartA[[x, y]];
numTable[x_, y_ /; EvenQ[y]] :=
InputField[Dynamic[initPtsPartA[[x, y]],
If[0 < # <= 10, initPtsPartA[[x, y]] = #, 0] &

], Number, ContinuousAction -> True, FieldSize -> 2];
initPtsPartSum[x_, y_, col_] :=
Setting[Dynamic@Total[initPtsPartA[[x ;; y, col]]]];
SchoolAPts = (Total[initPtsPartA[[1 ;; 3, #]]] &) /@ {1, 3};
StudentAPts = (initPtsPartSum[1, 3, #] &) /@ {2, 4};
Dynamic@Column[{Grid[
Append[Array[numTable, {3, 4}], (initPtsPartSum[1, 3, #] &) /@
Range[4]]], {"Just Testing Values:", initPtsPartSum[1, 3, 1],
initPtsPartSum[1, 3, 2], initPtsPartSum[1, 3, 3],
initPtsPartSum[1, 3, 4], "Student Pts only:",
StudentAPts}, {"seems to work now",
5*initPtsPartSum[1, 3, 2] + 10, initPtsPartSum[1, 3, 4] > 30,
Total[(initPtsPartSum[1, 3, #] &) /@
Range[4]], (Total@StudentAPts)/(Total@
SchoolAPts)}, {"seems to work now",
StudentMinAchieved = (StudentAPts[[1]]/SchoolAPts[[1]] >
mark4) && (StudentAPts[[2]]/SchoolAPts[[2]] > mark4)}}]]




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.