I would like to execute the following code, in which if the condition is true it should execute two instructions instead of one. When I run the code the instructions are executed, but no result is shown.
Ac = Input[];
Print[Ac];
If[Ac == 1,
instruction1
var := instruction2;
];
the instruction1 should show a grid in which you can modify the value of 4 parameters, and the instruction2 should use the value of these dyanmic variables in order to compute the result.
Instruciton1 is:
Grid[
{{"", "Theta", "d", "Alpha", "a"},
{"Link1",
InputField[Dynamic[Subscript[th, 1]], FieldSize -> 3],
InputField[Dynamic[Subscript[d, 1]], FieldSize -> 1],
InputField[Dynamic[Subscript[alpha, 1]], FieldSize -> 4],
InputField[Dynamic[Subscript[x, 1]], FieldSize -> 1]
}}, Frame -> Darker[Gray, .6],
Alignment -> {{Left, {Center}}}
]
Isntruction2 is:
linea[Dynamic[Subscript[th, 1]], Dynamic[Subscript[d, 1]],
Dynamic[Subscript[alpha, 1]], Dynamic[Subscript[x, 1]]]
Instruction1 and Instruction2 give the following result, cf image.! image
I haven't found any documentation about it. Is it possible to use the If function in Mathematica or should I use another one?
;character. To instruct the system to print an expression, usePrint. – Szabolcs Jan 17 at 17:00a; b;is interpreted asCompoundExpresion[a, b, Null], andNullreturns nothing. Usea; b, instead, which drops theNullfromCompoundExpresion. – rcollyer Jan 17 at 17:08Ifstatement essentially verbatim what you're running? If so, you're missing a semi-colon afterinstruction1. – rcollyer Jan 17 at 18:19