Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #9671

Re: What does NotebookDirectory[] do for .m files?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!newsfeeds.sol.net!post2.nntp.sol.net!posts.news.twtelecom.net!nnrp3.twtelecom.net!not-for-mail
From "Alexey Popkov" <lehin.p@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: What does NotebookDirectory[] do for .m files?
Date Mon, 16 Apr 2012 10:09:18 +0000 (UTC)
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Sender steve@smc.vnet.net
Approved Steven M. Christensen <steve@smc.vnet.net>, Moderator
Message-ID <jmgr4e$pgr$1@smc.vnet.net> (permalink)
References <jm8qeg$ja9$1@smc.vnet.net> <jmdsop$ac3$1@smc.vnet.net>
Lines 39
NNTP-Posting-Date 16 Apr 2012 10:11:48 GMT
NNTP-Posting-Host 43118dc0.news.twtelecom.net
X-Trace DXC=UcAE[U?IE29B8ck_2OIRd8C_A=>8kQj6=2f3;U>_oji9^1LZeUjd\<:EFiONJ7[Go60F>aU0a@b9<
X-Complaints-To abuse@twtelecom.net
Xref csiph.com comp.soft-sys.math.mathematica:9671

Show key headers only | View raw


"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


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