MathGroup Archive 2004

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

Search the Archive

Getting the file name in a package

  • To: mathgroup at smc.vnet.net
  • Subject: [mg52885] Getting the file name in a package
  • From: Geronimo <kalymereauKILLSP at Myahoo.fr>
  • Date: Thu, 16 Dec 2004 03:40:18 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

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: SymbolShape
  • Next by Date: Re: Reverse Hash Function
  • Previous by thread: Re: Many keys not working under Linux Mandrake 10.1
  • Next by thread: Re: Getting the file name in a package