Here's an example of writing a completely new task in CASA. It is assumed you have CASA and CASACORE installed and all supported and needed libraries are defined through the makedef hierarchies. Your code will have to go in the CASA code (a.k.a. casa non-core) tree. This is the directory where you find subdirectories such as nrao, install and ionosphere, to name a few.