Maple Professionel
Maple Académique
Maple Edition Étudiant
Maple Personal Edition
Maple Player
Maple Player for iPad
MapleSim Professionel
MapleSim Académique
Maple T.A. - Suite d'examens de classement
Maple T.A. MAA Placement Test Suite
Möbius - Didacticiels de mathématiques en ligne
Machine Design / Industrial Automation
Aéronautique
Ingénierie des véhicules
Robotics
Energie
System Simulation and Analysis
Model development for HIL
Modélisation du procédé pour la conception de systèmes de contrôle
Robotics/Motion Control/Mechatronics
Other Application Areas
Enseignement des mathématiques
Enseignement de l’ingénierie
Enseignement secondaire et supérieur (CPGE, BTS)
Tests et évaluations
Etudiants
Modélisation financière
Recherche opérationnelle
Calcul haute performance
Physique
Webinaires en direct
Webinaires enregistrés
Agenda des évènements
Forum MaplePrimes
Blog Maplesoft
Membres Maplesoft
Maple Ambassador Program
MapleCloud
Livres blancs techniques
Bulletin électronique
Livres Maple
Math Matters
Portail des applications
Galerie de modèles MapleSim
Cas d'Etudes Utilisateur
Exploring Engineering Fundamentals
Concepts d’enseignement avec Maple
Centre d’accueil utilisateur Maplesoft
Centre de ressources pour enseignants
Centre d’assistance aux étudiants
ModuleLoad - function to apply prior to loading a module
ModuleUnload - function to apply prior to deleting a module
Calling Sequence
module() export ModuleLoad, ...; ... end module;
module() export ModuleUnload, ...; ... end module;
Description
If a ModuleLoad local or export is present, then this procedure is called when the module is read from the Maple repository in which it is located.
If a ModuleUnload local or export is present, then this procedure is called when the module is destroyed. A module is destroyed either when it is no longer accessible and is garbage collected, or when Maple exits.
A module may be no longer accessible, and hence subject to garbage collection before the procedure is executed, but become accessible again during the execution of that procedure. In this case, the module is not garbage collected. When it eventually is garbage collected or Maple exits, the ModuleUnload procedure is not executed again.
The ModuleLoad and ModuleUnload procedures are called with no arguments.
For the ModuleLoad option to perform correctly, the entire module in which it appears must be saved to the repository. Also, if you save a member of a module that uses ModuleLoad and/or , but do not save the module, then the specified procedure(s) will not be called.
An alternate name can be designated as ModuleLoad or ModuleUnload by using option load = lname and option unload = uname respectively, where lname and uname are exports or locals of the module.
Examples
This module is initialized by calling the procedure ModuleLoad when the module is read from a repository. It executes the procedure ModuleUnload when the module is garbage collected or Maple exits.
P := module() export Area, NewTri; local ModuleLoad, ModuleUnload; NewTri := proc( v1::[numeric,numeric], v2::[numeric,numeric], v3::[numeric,numeric] ) return 'TRI'(v1,v2,v3); end proc; Area := proc( t::TRI ) local gt; uses geometry; gt := triangle(A123, [seq(point(cat('A',i),op([i,1..2],t)),i=1..3)]); area(A123); end proc; ModuleLoad:= proc( ) # register a type TypeTools[AddType]( TRI, 'patfunc([numeric,numeric], [numeric,numeric], [numeric,numeric],TRI)' ); # display a message printf("Loading module P\n"); end proc: # Explicitly call ModuleLoad here so the type is registered when this # code is cut&pasted in. ModuleLoad gets called when the module is # read from the repository, but the code used to define a module # (like the command below) is not called at library read time. ModuleLoad(); ModuleUnload:= proc( ) # print a message printf("Module P is going away\n"); end proc: end module:
Loading module P
See Also
module, module,option, ModuleApply, ModulePrint, repository, savelib
Download Help Document