Message Boards Message Boards

0
|
6231 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Use of FileNameSetter

Hi all,

I´m trying to build a little function that lets me choose a file from a directory an returns me the filename, so I can then read in the contents of this file. FileNameSetter does this job, but I have difficulties to integrate this function in a whole module. I tried a lot, but it seem that I simply have not the right understanding, so I´m stuck in the enclosed example notebook. Can someone give me a hint how I can manage this.

readFile[liste_] := Module[{listLoc = "", temp},

temp = {FileNameSetter[Dynamic @ f,], Dynamic @ f};

 listLoc = Import[f, "Words"]   (* not working :-( *)

]

Greetings

Mike

Attachments:
POSTED BY: Michael Gamer
2 Replies

Hi Nasser,

and thanks a lot, this helps me out :-) I´ve really been stuck in this FileNameSetter-world, which was simply the wrong way.

Thank you!

Mike

POSTED BY: Michael Gamer

choose a file from a directory an returns me the filename, so I can then read in the contents of this file

getContent[] := Module[{fileName, content = {}},
  fileName = SystemDialogInput["FileOpen"];
  If[fileName =!= $Canceled, content = Import[fileName]];
  content
  ]

called as

content = getContent[]
POSTED BY: Nasser M. Abbasi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract