Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #9671
| From | "Alexey Popkov" <lehin.p@gmail.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: What does NotebookDirectory[] do for .m files? |
| Date | 2012-04-16 10:09 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <jmgr4e$pgr$1@smc.vnet.net> (permalink) |
| References | <jm8qeg$ja9$1@smc.vnet.net> <jmdsop$ac3$1@smc.vnet.net> |
"David Bailey" <dave@removedbailey.co.uk>: news:jmdsop$ac3$1@smc.vnet.net... > On 13/04/2012 10:08, Jesse Perla wrote: >> NotebookDirectory[] correctly gives the location of the notebook for my >> .nb files, but I cannot seem to find an equivalent for my .m files? Is >> there another approach? >> > > There are two distinct cases here. > > If you open a .m file in the FrontEnd, it is treated like a notebook, > and NotebookDirectory will work on it. > > If you use Get ( << ) to open the file, or it is opened because of a > Needs command, then things get a bit trickier. While the .m file is > being loaded in, $InputFileName is set to the name of the .m file, but > not to the complete path! It seems that in version 8.0.4 $InputFileName gives complete path to the .m-file. Evaluating << ExampleData/input.m gives $Input is ExampleData/input.m $InputFileName is C:\Program Files\Wolfram Research\Mathematica\8.0\Documentation\English\System\ExampleData\input.m while evaluating FilePrint["ExampleData/input.m"] gives Print["$Input is ",$Input]; Print["$InputFileName is ",$InputFileName];
Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
What does NotebookDirectory[] do for .m files? Jesse Perla <jesseperla@gmail.com> - 2012-04-13 09:08 +0000
Re: What does NotebookDirectory[] do for .m files? Vince Virgilio <blueschi@gmail.com> - 2012-04-14 07:16 +0000
Re: What does NotebookDirectory[] do for .m files? David Bailey <dave@removedbailey.co.uk> - 2012-04-15 07:18 +0000
Re: What does NotebookDirectory[] do for .m files? "Alexey Popkov" <lehin.p@gmail.com> - 2012-04-16 10:09 +0000
Re: What does NotebookDirectory[] do for .m files? Jesse Perla <jesseperla@gmail.com> - 2012-04-18 07:55 +0000
csiph-web