next | previous | forward | backward | up | top | index | toc | Macaulay2 web site
Macaulay2Doc > The Macaulay2 language > packages > needsPackage

needsPackage -- load a package if not already loaded

Synopsis

Description

The file PACKAGENAME.m2 should be on the load path and should contain a package named PACKAGENAME.

For example, to load the sample package FirstPackage:

If the variable notify is set to true, then an informational message is displayed after the file is loaded.

i1 : notify = true

o1 = true
i2 : needsPackage "FirstPackage"
--database not present: /builddir/build/BUILD/Macaulay2-1.3.1-r10737/StagingArea/common/lib/Macaulay2/s390-Linux-Fedora-15/FirstPackage/cache/rawdocumentation-abcd-4.db
--beginDocumentation: reading the rest of /builddir/build/BUILD/Macaulay2-1.3.1-r10737/Macaulay2/packages/FirstPackage.m2
--package "FirstPackage" loaded
--loaded /builddir/build/BUILD/Macaulay2-1.3.1-r10737/Macaulay2/packages/FirstPackage.m2

o2 = FirstPackage

o2 : Package
i3 : needsPackage "FirstPackage"

o3 = FirstPackage

o3 : Package
The second time the package was not reloaded.

See also

Ways to use needsPackage :