This question already has an answer here:

Given a directory path and some .m files in it, I want load these packages files mannually outside notebooks, so I created Palette using code:

  Framed@Column[{(FileNameSetter[Dynamic[path], "Directory"]),
      "LoadPackage", (SetOptions[Get, CharacterEncoding -> "UTF8"];
                      If[ Not@DirectoryQ@ToString@path,
                      Get /@ FileNames["*.m", {path}];
      Appearance -> "Palette"]
     }], WindowTitle -> "Test"];

enter image description here

When I want load packages, I click [Browse] to choose the directory firstly, then click [LoadPackage], but it does not work, what's the problem?


marked as duplicate by Kuba front-end Dec 9 '18 at 8:23

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ Comments are not for extended discussion; this conversation has been moved to chat. $\endgroup$ – Kuba Dec 8 '18 at 14:25
  • $\begingroup$ Let me know if you disagree with closing. But from your answer and a conversation in chat I think that answer is what you need. It also shows why it is crucial to explain the problem and not say generic "it does not work". It can save people's time in future. $\endgroup$ – Kuba Dec 9 '18 at 8:26

By using the Palette LoadPackage, functions in package files will be loaded immediately but not listed in intellisense context at once, unless one of the functions is to be used or queried i.e. Names["*"]. I have tested to fix it but not succeeded.

enter image description here


Export["test.m", "BeginPackage[\"MyPackage`MyPrintTool`\"] 
myPrint::usage := \"myPrint does something\" 

Begin[\"`Private`\"] (* Begin Private Context *) 




EndPackage[]", "Text"]; 

Framed@Column[{(FileNameSetter[Dynamic[path], "Directory"]), 
Button["LoadPackage", (Get /@ FileNames["*.m", {path}];), 
Appearance -> "Palette"]}], WindowTitle -> "Test"];
  • $\begingroup$ What do you mean? Is $ContextPath not up to date? $\endgroup$ – Kuba Dec 9 '18 at 7:42
  • $\begingroup$ Generally, when package files loaded, If you stike keyboards to use function, the notebook will show you a list to choose quickly(intellisense). In the upper case would not unless the new inputed funtion(s) evaluated. $\endgroup$ – Jerry Dec 9 '18 at 8:14
  • $\begingroup$ Intellisense is VS related term, I for example was not aware of what are you talking about. Please target your wording at MMA users and assume nothing else or provide clarification/links etc. $\endgroup$ – Kuba Dec 9 '18 at 8:24
  • $\begingroup$ I upload a picture upper, I think it's the Intellisense in MMA. $\endgroup$ – Jerry Dec 9 '18 at 8:36
  • $\begingroup$ My point is that Intellisense does not mean anything in MMA. No one calls autocompletion Intellisense here. If you google it it points at VS feature. $\endgroup$ – Kuba Dec 9 '18 at 8:45

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