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:

CreatePalette[
  Framed@Column[{(FileNameSetter[Dynamic[path], "Directory"]),
     Button[
      "LoadPackage", (SetOptions[Get, CharacterEncoding -> "UTF8"];
                      If[ Not@DirectoryQ@ToString@path,
                          Return@$Failed
                      ];
                      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 yesterday

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.

  • Comments are not for extended discussion; this conversation has been moved to chat. – Kuba 2 days ago
  • 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. – Kuba yesterday

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

SetDirectory@$TemporaryDirectory; 
CreateDirectory["files"]; 
SetDirectory@"files"; 

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

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

myPrint[DateString[CurrentDate[]]<>$InputFileName] 

myPrint[message_]:=Print[message] 


End[] 

EndPackage[]", "Text"]; 


CreatePalette[ 
Framed@Column[{(FileNameSetter[Dynamic[path], "Directory"]), 
Button["LoadPackage", (Get /@ FileNames["*.m", {path}];), 
Appearance -> "Palette"]}], WindowTitle -> "Test"];
  • What do you mean? Is $ContextPath not up to date? – Kuba yesterday
  • 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. – Jerry yesterday
  • 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. – Kuba yesterday
  • I upload a picture upper, I think it's the Intellisense in MMA. – Jerry yesterday
  • 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. – Kuba yesterday

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