This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)
 Documentation / Mathematica / Built-in Functions / Input and Output / File Input  /
Needs

  • Needs[" context `"] loads an appropriate file if the specified context is not already in $Packages.
  • Needs[" context `", " file "] loads file if the specified context is not already in $Packages.
  • Needs[" context `"] calls Get[" context `"]. By convention, the file loaded in this way is the one which contains a package that defines context `.
  • Example: Needs["Collatz`"] typically reads in a file named Collatz.m.
  • See the Mathematica book: Section 2.6.10.
  • See also: Get, DeclarePackage, FileNames.
  • Related package: Utilities`Package`.

    Further Examples

    This loads the package PlotField if it has not already been loaded.

    In[1]:=

    Now these package functions are available.

    In[2]:=

    Out[2]=