WolframLang: Load a Package or File
Load Any File of WolframLang Code
Get[filename]
Get[fullpath]
Load a file.
It search file in dirs in $Path
.
Get[ "c:/Users/xah/Desktop/Xah_WolframLang_packages/PlaneCurvePlot/PlaneCurvePlot.wl" ]
Load File in Current Dir
(* load a file, where the file is in the same dir as the current notebook *) Get[StringJoin[NotebookDirectory[], "myfile.wl"]]
(* load a file, where the file is in the same dir as the running script *) Get[StringJoin[ DirectoryName[ $InputFileName ] , "myfile.wl"]]
Load a Package by Context Name
Another way to load a package, is to call Needs
.
This is a slightly higher level, based on
Context Name
, not a hard file path.
It'll only load the file if the context is not already loaded.
Needs[ ContextName ]
-
Load a file if ContextName is not already in
$Packages
The file name to load is based on ContextName to filename convention. You can give a second argument for a specific file name.
〔see WolframLang: Context (Namespace)〕
Once it figured out a file name, it calls
Get
to load the file.in general, for
Needs
to work, you should put packages in the Wolfram Library Dir, in theApplications
orAutoload
subdirectory. 〔see WolframLang: Init Dir, Library Dir〕Needs[ "PlaneCurvePlot`" ]
WolframLang, Package, Load File
WolframLang, Shell Tasks
- WolframScript Tutorial
- WolframLang: File Name Extension
- WolframLang: Shell Tasks
- WolframLang: Navigate Directory
- WolframLang: List Files (Walk Directory)
- WolframLang: File Path Functions
- WolframLang: Delete Dir
- WolframLang: is File or Dir
- WolframLang: File Exist
- WolframLang: Get File Date
- WolframLang: Get File Size
- WolframLang: Print File Content
- WolframLang: Get File Hash
- WolframLang: Read File
- WolframLang: Write File
- WolframLang: Load a Package or File
- WolframLang: Get Environment Variable
- WolframLang: Date Time
- WolframLang: Find/Replace Script