5.15 How to create a package?

First create the module:

restart; 
 
nma:= module() 
      option package; 
      export getMaxMatrix; 
      getMaxMatrix := proc (M::{matrix, Matrix}) 
          local C, r, c, mx, L, p; 
          C := op(`if`(M::Matrix,[1, 2],[2,2,2]),eval(M)); 
          L := map(op,convert(M,listlist)); 
          mx := max(L[]); member(mx,L,'p'); 
          r := iquo(p,C,'c'); 
          mx, `if`(c = 0,[r, C],[r+1, c]) 
       end proc; 
end module; 
 
A:= Matrix( [ [1, 2, 3] , 
              [3, 6, 7] , 
              [5, 6, 9] , 
              [7, 7, 7] 
            ]); 
 
nma[getMaxMatrix](A);|
 

Gives 9, [3, 3]. Now save the module.

savelibname := "C:/MAPLE_PACKAES"; 
march('create', savelibname, 20);
 

now save the library to disk.  savelib(nma);

Now we can test everything by reinitialize everything and reload the library.

>restart 
#Add my library to LIBNAME 
>libname:="C:/MAPLE_PACKAGES",libname; 
> A:=matrix( [ [1,2,3],[4,6,9] ]); 
>with(nma); 
>nma[getMaxMatrix](A);
 

Now to print a proc() in the package, do

>interface(verboseproc=3); 
> print(nma[getMaxMatrix]);
 

Now you can list what packages exist in the archive:

march('list',savelibname); 
march('extract',savelibname,":-1.m","C:MAPLE_PACKAGES/t.m")
 

Some notes. need to clean later

> module1lib:=`module1\\lib`; 
> system("md "||module1lib); 
> march('create',module1lib,100); 
> makehelp(module1,`module1/module1.mws`,module1lib): 
> makehelp(`module1/export1`,`module1/export1.mws`,module1lib): 
> savelibname:=module1lib: ### doesn't affect current libname 
> savelib(module1); ### no error message 
> restart; 
> module1lib:="module1\\lib": 
> libname:=module1lib,libname; ### now Maple will find module1 
> with(module1); 
> ?module1
 

Also there is a long thread here on Maple prime on making personal packages in Maple How-To-Create-A-Personal-Package