HowTo:Implement an ApCoCoA-2 Package
This page describes how to write a proper ApCoCoA-2 package in order to contribute it to ApCoCoA-2. For a complete description on how to contribute a package, see HowTo:Contribute an ApCoCoA Package.
Note: In the following description, words marked as <<word>>
are placeholders, i.e. you should replace this text after copying.
Writing Functions
At the very first, you have to create a file <<package name>>.cpkg5
. This is the package file and will later be located in the folder
/plugins/apcocoa/lib/cocoa/packages/apcocoa/
in the apcocoa directory. If the package is self-contained, you can first put it anywhere and load it into ApCoCoA or CoCoA-5 for testing the functions. Otherwise, we recommend putting it in the ApCoCoA package directory on your system and test it using ApCoCoA. The package can be reloaded for testing using the command
Source MEMORY_ApCoCoA_Packages_Path + "<<package name>>.cpkg5";
The following is a minimal example for the package:
Package $apcocoa/<<package name>>
export skip;
EndPackage;
The line export skip;
is needed in order to tell CoCoA that this package does not export any functions. If you want to export functions, you can delete this line.
Afterwards you can now add the functions you want to have in the package. For instance, if you write
Package $apcocoa/<<package name>>
export skip;
Define Foo()
PrintLn "Foo";
EndDefine; -- Foo
EndPackage;
you can call this function from CoCoA with $apcocoa/<<package name>>.foo();
.
Adding package info
At first, add the following copyright information at the top of the package file (above Package $apcocoa/<<package name>>
):
Then create two functions:
Define About() PrintLn " Topic : <<Topic name (single word)>>"; PrintLn " Keywords: <<keywords>>"; PrintLn " Authors : <<author name>>"; PrintLn " Version : <<current CoCoA version>>"; PrintLn " Date : <<release date>>"; EndDefine; -- About Define Man() PrintLn "Recommended Alias:"; PrintLn " Alias <<alias>> := $apcocoa/<<package name>>;"; PrintLn; ... EndDefine; -- Man
The function Man()
should contain a short description for every function contained in the package.
For a clearer description of About()
see the example below.