2
$\begingroup$

Using an underscore with the SetDirectory command works fine.

SetDirectory["D:\\at_work\\mathematica\\programming_maeder"]

Now I can load a package using Get["ComplexMap`"] or Needs["ComplexMap"].

But if I set the directory to the directory above

SetDirectory["D:\\at_work\\mathematica"]

The Get or Needs commands fails.

Get["programming_maeder`ComplexMap`"]

Since it is within a string I would have thought the above statement would work. Is there a way to use the underscore here?

A workaround is to rename the directory programmingMaeder but I would prefer to use the underscore.

$\endgroup$
  • 2
    $\begingroup$ You can either rename the directory and use the backtick notation or keep the directory name and use the normal path syntax of your operating system, i.e. Get["D:\\at_work\\mathematica\\programming_maeder\\ComplexMap.m"]. The idea behind the backtick notation is that users will be able to simply write the package context after << to load the package. This requires the context name to agree with the directory and file names. Context names simply cannot contain underscores. $\endgroup$ – Szabolcs Feb 11 '15 at 15:19
  • $\begingroup$ have you tried the Get[name,Path->{}] form? $\endgroup$ – george2079 Feb 11 '15 at 17:56
  • $\begingroup$ The Get command with the complete path suggested by Szabolcs works fine. Also the form suggested by george2079 works. Thank you both $\endgroup$ – Jack LaVigne Feb 11 '15 at 23:58
1
$\begingroup$

The comment given by Szabolcs works as an answer. He suggested using:

Get["D:\\at_work\\mathematica\\programming_maeder\\ComplexMap.m"]

He also made it clear that one is not allowed to use an underscore in a Context name.

The comment given by george2079 also works as an answer. He suggested using:

Get["ComplexMap`", 
 Path -> {"D:\\at_work\\mathematica\\programming_maeder"}]

or

Get["ComplexMap.m", 
 Path -> {"D:\\at_work\\mathematica\\programming_maeder"}]

I hope I am doing the correct thing by taking their comments and posting them as an answer.

$\endgroup$
  • $\begingroup$ that's appropriate. Go ahead and accept it after a while. $\endgroup$ – george2079 Feb 13 '15 at 20:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.