Wolfram: Load a Package or File
Load Any File of WolframLang Code
Get[fullpath]
→ load a file.
Get[filename]
Load a file by file name.
It search file in dirs in $Path
.
〔see Wolfram: Search Paths $Path for Loading File〕
Get[ "c:/Users/xah/Desktop/Xah_WolframLang_packages/PlaneCurvePlot/PlaneCurvePlot.wl" ]
Load File in Current Notebook Dir
(* load a file, where the file is in the same dir as the current notebook *) Get[StringJoin[NotebookDirectory[], "myfile.wl"]]
Load File in Current Script Dir
(* 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 Wolfram: 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 Wolfram: Init Dir, Library Dir〕Needs[ "PlaneCurvePlot`" ]
WolframLang, Package, Load File
WolframLang, Shell Scripting Tasks
- Wolfram: Shell Scripting Tasks
- Wolfram: Navigate Directory
- Wolfram: List Files (Walk Directory)
- Wolfram: File Path Functions
- Wolfram: Delete Dir
- Wolfram: is File or Dir
- Wolfram: File Exist
- Wolfram: Get File Date
- Wolfram: Get File Size
- Wolfram: Print File Content
- Wolfram: Get File Hash
- Wolfram: Read File
- Wolfram: Read File from Web
- Wolfram: Write File
- Wolfram: Load a Package or File
- Wolfram: Get Environment Variable
- Wolfram: Date Time
- Wolfram: Find Replace Script