Re: How can I add a new function in options.c?



 
the 'Defining New Functions' page in the manual appears empty in 'https://help.gnome.org/users/gnumeric/stable/sect-extending-functions.html.en', perhaps someone can add a chapter similar to the text below which made it for acsglster to implement his changes.
 
For those interested in the derivatives matter he has published and commented his work in https://github.com/steve-g-lynn/gnumeric-options-plugin.
 
--------------------------------------------------------------------------------------------------
change functions in gnumeric or - highly recommended - add variants instead:
 
some - old - info about programming gnumeric is in 'main_dir/doc/developer'.
 
assuming you already managed to compile gnumeric and have found that most functions reside in subdirs of 'plugins', there mostly in 'functions.c' ... poor mans simple approach:
take a function already existing there, if given together with it's 'help section' starting with sthg. like 'static GnmFuncHelp const help_function_name', most likely a block from one '/* info what function */' comment to the next one,
for first tests try an easy one, e.g. without subroutines like 'function_name1', and copy below itself,
in first step only change the function_name and! the 'help_function_name',
 
I. additional step to learn: add an appropriate entry in the 'GnmFuncDescriptor const xxxxxx_functions' section at the bottom of the file, copy from original function and adapt name and help_name,
 
II. add. step to learn: add an appropriate entry in 'plugin.xml.in' in that directory, copy from original function and change name, do not change plugin.xml, it's overwriten in compilation,
 
re-compile, and check if it's working, if not read compiler comments, if yes adapt to your needs,
be aware to use 'gnm_float' instead of 'double' or 'long double' as datatype, and - for most cases - 'gnm_code_function' instead of 'code_function' to enable datatype independent code, e.g. gnm_float x = gnm_pow( gnm_float y, gnm_float z ), instead of double x = pow( double y, double z ),
 
'numbers.h' in 'src' directory is the main dispatcher between double vs. long double and c-code vs. 'gnumeric substitutes in goffice' functions,
 
the rest is up to you, your knowledge in 'pure-C' programming, your luck in guessing the meaning of parameters and your patience to approach your goal in small steps,
 
what helped me immensely - after difficulties to get it running - is 'WHENCE' together with 'GG', 'SS' and 'confect' by John Denker, see https://www.av8n.com/gnumeric/ , it allows several almost independent gnumeric installations side by side, and thus 'trial and error' while keeping an undisturbed original as reference.
 
hope that helps a little, hope I didn't miss steps ... 
--------------------------------------------------------------------------------------------------
 
 
_______________________________________________ gnumeric-list mailing list gnumeric-list gnome org https://mail.gnome.org/mailman/listinfo/gnumeric-list


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]