# How to use If with long instructions?

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"},
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?

-
Note that Grid does not show a grid. It is a grid (it represents a grid). The system just happens to show the result of your last calculation, if you don't follow it with a ; character. To instruct the system to print an expression, use Print. –  Szabolcs Jan 17 at 17:00
When using compound expressions, it is the output of the last term that is returned. But, a; b; is interpreted as CompoundExpresion[a, b, Null], and Null returns nothing. Use a; b, instead, which drops the Null from CompoundExpresion. –  rcollyer Jan 17 at 17:08
@rcollyer : same result without the ; after the second instruction. –  narutov6 Jan 17 at 17:30
@Szabolcs : I think that the problem is related to the Grid function with Dynamic variables. Is it possible to show a normal grid in an If without using the Print funciton? Anyway with if[cond,Print[Grid[...]]; Print[Instruction2]]; it works! Thank you –  narutov6 Jan 17 at 18:01
Is your If statement essentially verbatim what you're running? If so, you're missing a semi-colon after instruction1. –  rcollyer Jan 17 at 18:19
show 2 more comments