How about the Null part of my question? Any way to suppress it?
For the second part, I do not see a Null printed, but the actual If
statement itself
![enter image description here](/c/portal/getImageAttachment?filename=8132Untitled.png&userId=89105)
The reason is because that is how If
works when it has one branch and it is not true. For example
![enter image description here](/c/portal/getImageAttachment?filename=10130Untitled.png&userId=89105)
To workaround this, use the third branch of If
which tells it what to do if it can't decide between True and False
![enter image description here](/c/portal/getImageAttachment?filename=6430Untitled.png&userId=89105)
So for your first example, to eliminate the Null you can type in a value for mats
other than "1", is to give it a value to use for the second branch. Also, it is best to initialize mats
to "1" for first time, so the code becomes
mats = "1";
InputField[Dynamic[mats], String]
Dynamic[If[mats == "1",
CreateWindow[DialogNotebook[{TextCell["Not a valid matrix."], DefaultButton[DialogReturn[]]}]]
, "waiting..."], TrackedSymbols :> {mats}]
You do not need a value for the third branch (the undecided one) since now mats is initialized to some specific value.