> FrAid
 

Writing FrAid Library Functions

Note
You need to know some Java to use this feature.

FrAid Library Functions

The Java written FrAid library functions are much faster than those written in FrAid. Another difference is that they once loaded they can not be overriden. Technically speaking a FrAid library function is any instance of a subclass of the ComplexFunction class loaded in the FrAid symbol table. Another requirement for proper loading is that the function's class lives in a package named "functions" (no matter how it's parent packages are named). There are plenty of examples in the FrAid sources but may be the simplest way to create and immediately execute your first FrAid library function is using the simple org.fraid.utils.CreateFunction code generator. Follow these steps:

  • Download frd_gen_code.jar into the bin directory where all other FrAid jars live.
  • Run java -cp frd_gen_code.jar org.fraid.utils.CreateFunction -source myFun. Hint: see what files were created and where they are.
  • Edit the generated functions/myFun.java file and make it do whatever you want. If this is the first time you do this you may skip this step and just observe how this works. What the default generated function does is just replicate the behavior of the add library function.
  • Run java -cp frd_gen_code.jar org.fraid.utils.CreateFunction -compile myFun. If you get any compile errors try the -printOnly option and run the compilation manually
  • Run fraid.sh or fraid.bat
  • Execute your function - for the above example: myFun(2,2);
  • Run java -cp frd_gen_code.jar org.fraid.utils.CreateFunction -delete myFun if you want to start all over.