MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Getting the file name in a package

  • To: mathgroup at
  • Subject: [mg52919] Re: Getting the file name in a package
  • From: "Jens-Peer Kuska" <kuska at>
  • Date: Fri, 17 Dec 2004 05:18:26 -0500 (EST)
  • Organization: Uni Leipzig
  • References: <cpri7j$qsd$>
  • Sender: owner-wri-mathgroup at


what may ContextToFileName[] do ?
BTW a package can be in a notebook and does not
need a file name.


"Geronimo" <kalymereauKILLSP at> schrieb im Newsbeitrag 
news:cpri7j$qsd$1 at
> Hi
> I have a package (.m) that produces some output in an external file. As 
> the
> computation is quite long, I would like to avoid it if the output file is
> more recent than the last modification of the package (since the output
> only depends on what is in the package).
> So I need to extract the file name of the package within itself (and then
> test the date with FileDate). As the context name is related to the file
> name, I use:
> BeginPackage["TestPack`"]
> (blabla)
> Begin["`Private`"]
> currentFileName = StringDrop[Context[], -9] <> ".m"
> (blabla)
> End[]
> EndPackage
> Since within the Private context the Context[] command gives
> TestPack`Private` and `Private` is 9 characters long, it works:
> currentFileName is equal to "TestPack.m". However I find this solution
> quite cumbersome, is there a more obvious way to do that?
> Thank you
> Geronimo

  • Prev by Date: Re: plotting two functions on the one graph
  • Next by Date: Re: Getting the file name in a package
  • Previous by thread: Getting the file name in a package
  • Next by thread: Re: Getting the file name in a package