Wolfram: Load a Package or File (Get, Needs)
Get (Load a File of Wolfram Code)
Get[filename]-
🔸 SHORT SYNTAX:
<<filename- Load a file of Wolfram language code, by file name.
- filename can also be file fullpath.
- If filename is not fullpath, search the file in
$Path. [see Wolfram: Search Paths $Path]
Get[ "PlaneCurvePlot.wl" ] Get[ "c:/Users/xah/git/PlaneCurvePlot/PlaneCurvePlot.wl" ]
Example. Load File in Current Notebook Dir
(* load a file that is in the current notebook dir *) Get[FileNameJoin[ {NotebookDirectory[], "myfile.wl"}] ]
Example. Load File in Current Script Dir
(* load a file that is in the same dir as the running script *) Get[FileNameJoin[ {DirectoryName[ $InputFileName ] , "myfile.wl"]}]
Load a Package by Context Name
Needs[ ContextName ]-
Load a file if ContextName is not already in
$PackagesThe file name to load is based on ContextName to filename convention. You can give a second argument for a specific file name.
Once it figured out a file name, it calls
Getto load the file.in general, for
Needsto work, you should put packages in the Wolfram Library Dir, in theApplicationsorAutoloadsubdirectory.Needs[ "PlaneCurvePlot`" ]