MathGroup Archive 2004

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

Search the Archive

Re: Getting the file name in a package

  • To: mathgroup at
  • Subject: [mg52951] Re: Getting the file name in a package
  • From: Bill Rowe <readnewsciv at>
  • Date: Fri, 17 Dec 2004 05:20:18 -0500 (EST)
  • Sender: owner-wri-mathgroup at

On 12/16/04 at 3:40 AM, kalymereauKILLSP at (Geronimo) wrote:

>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:




>currentFileName = StringDrop[Context[], -9] <> ".m"




>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?

The most direct way would be to simply do


Your method relies on the assumption the filename of the package matches the name of the context. Since the name of the context is hard coded, there is no advantage to your method over simply hard coding currentFileName to a known value.
To reply via email subtract one hundred and four

  • Prev by Date: Re: Getting the file name in a package
  • Next by Date: Re: plotting two functions on the one graph
  • Previous by thread: Re: Getting the file name in a package
  • Next by thread: TracePrint[GUIKitHello]| wc -l; 1205456