# Type of Dynamic object and GUI-construction for file import [closed]

It's not clear what the Dynamic objects really are. For example, if I define the following

x=1;
Dynamic[x];
y=Dynamic[x];

we can see that all the three are changing simultaneously but NumberQ[x] gives True while NumberQ[y] and NumberQ[Dynamic[x]] give False. In fact, I don't know what they are, they are neither string nor other type. So what are their type and how to transform them into other type I need ?

More specifically, this question is encountered when I try to design a GUI in which I should have been able to input some file(data) by clicking the browse button. The code is presented,

DynamicModule[{path = "", data = "", status = 0},
Panel@
Column@
{Row@{"Input:",
FileNameSetter[Dynamic[FindFile@path,
(path = #; If[(path =!= $Failed || path =!=$Canceled) &&
FileExistsQ@path, data = Flatten@Import@path;
status = 1]) &],
"Open", {".dat" -> {"*.dat"}}],
InputField[Dynamic@path, String, Enabled -> False]
},
If[Dynamic[status] === 1, Dynamic@ListPlot[data],
}]

As you see, since I don't know the type of Dynamic object, === is used. But the If doesn't work here. Even if I choose the file I need, it just does not execute the right action.

So, does anybody know the problem or you may just have a better solution to realize such functionality ? Thank you.

(Btw, once the file is loaded and data is set, more sophisticated operation such as data analysis and other interactive manipulation shall be made.)

## closed as off-topic by Mike Honeychurch, MarcoB, user9660, RunnyKine, m_goldbergMar 15 '16 at 8:14

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Mike Honeychurch, MarcoB, Community, RunnyKine, m_goldberg
If this question can be reworded to fit the rules in the help center, please edit the question.

• You need to go back to the drawing board unfortunately. Dynamic is not what you apparently think it is ...but what it is is explained in detailed in the docs and various tutorials. – Mike Honeychurch Mar 15 '16 at 3:09

The place to start with Dynamic is the docs, in particular the tutorials. For me at least, I think the best way to think of Dynamic is that it dynamically updates pixels on your screen. This means that if something is not displayed Dynamic has no effect whatsoever ...other than possible deleterious effects that you have discovered.

NumberQ[y] cannot possible ever be True because your are asking whether something with head Dynamic is a number, which quite clearly it is not. If you want to test something that has Dynamic around it you would need to strip that away:

NumberQ[y]
NumberQ[y /. Dynamic -> Identity]
NumberQ[Setting@y]
(* False *)
(* True *)
(* True *)

Likewise, Dynamic[status] === 1 will always be False. I don't know what you data looks like -- are you sure you need FindFile (?) -- but this change to your code will work subject to the caveat that you understand your data and you understand Import and ListPlot

DynamicModule[{path = "", data = "", status = 0},

Panel@Column[{
Row[{"Input:",
FileNameSetter[
Dynamic[path, (path = #;
If[(path =!= $Failed || path =!=$Canceled) &&
FileExistsQ@path, data = Flatten@Import[path, "Data"];
status = 1]) &], "Open", {".dat" -> {"*.dat"}}],
InputField[Dynamic@path, String, Enabled -> False]}],
Dynamic@If[status === 1,
ListPlot[data],