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

newbie nullzwei via gnumeric-list <[email protected]> Fri, 5 Aug 2022 14:50:55 +0200
Newsgroups gmane.comp.gnome.apps.gnumeric
Message-ID <trinity-6ba700cc-5d40-44d0-90b5-e1b5c513c6c3-1659703855439@3c-app-gmx-bs60>
--===============7814937242860863843==
Content-Type: text/html; charset=UTF-8

<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div>&nbsp;</div>

<div>the <span class="title">&#39;Defining New Functions&#39; page in the manual appears empty in &#39;</span>https://help.gnome.org/users/gnumeric/stable/sect-extending-functions.html.en&#39;, perhaps someone can add a chapter similar to the text below which made it for acsglster to implement his changes.</div>

<div>&nbsp;</div>

<div>For those interested in the derivatives matter he has published and commented his work in <a href="https://github.com/steve-g-lynn/gnumeric-options-plugin" target="_blank">https://github.com/steve-g-lynn/gnumeric-options-plugin</a>.</div>

<div>&nbsp;</div>

<div>
<div>--------------------------------------------------------------------------------------------------</div>

<div>change functions in gnumeric or - highly recommended - add variants instead:</div>

<div>&nbsp;</div>

<div>some - old - info about programming gnumeric is in &#39;main_dir/doc/developer&#39;.</div>

<div>&nbsp;</div>

<div>assuming you already managed to compile gnumeric and have found that most functions reside in subdirs of &#39;plugins&#39;, there mostly in &#39;functions.c&#39; ... poor mans simple approach:</div>

<div>take a function already existing there, if given together with it&#39;s &#39;help section&#39; starting with sthg. like &#39;static GnmFuncHelp const help_function_name&#39;, most likely a block from one &#39;/* info what function */&#39; comment to the next one,</div>

<div>for first tests try an easy one, e.g. without subroutines like &#39;function_name1&#39;, and copy below itself,</div>

<div>in first step only change the function_name and! the &#39;help_function_name&#39;,</div>

<div>&nbsp;</div>

<div>I. additional step to learn: add an appropriate entry in the &#39;GnmFuncDescriptor const xxxxxx_functions&#39; section at the bottom of the file, copy from original function and adapt name and help_name,</div>

<div>&nbsp;</div>

<div>II. add. step to learn: add an appropriate entry in &#39;<a href="http://plugin.xml.in" target="_blank">plugin.xml.in</a>&#39; in that directory, copy from original function and change name, do not change plugin.xml, it&#39;s overwriten in compilation,</div>

<div>&nbsp;</div>

<div>re-compile, and check if it&#39;s working, if not read compiler comments, if yes adapt to your needs,<br/>
be aware to use &#39;gnm_float&#39; instead of &#39;double&#39; or &#39;long double&#39; as datatype, and - for most cases - &#39;gnm_code_function&#39; instead of &#39;code_function&#39; 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 ),</div>

<div>&nbsp;</div>

<div>&#39;numbers.h&#39; in &#39;src&#39; directory is the main dispatcher between double vs. long double and c-code vs. &#39;gnumeric substitutes in goffice&#39; functions,</div>

<div>&nbsp;</div>

<div>the rest is up to you, your knowledge in &#39;pure-C&#39; programming, your luck in guessing the meaning of parameters and your patience to approach your goal in small steps,</div>

<div>&nbsp;</div>

<div>what helped me immensely - after difficulties to get it running - is &#39;WHENCE&#39; together with &#39;GG&#39;, &#39;SS&#39; and &#39;confect&#39; by John Denker, see <a href="https://www.av8n.com/gnumeric/" target="_blank">https://www.av8n.com/gnumeric/</a> , it allows several almost independent gnumeric installations side by side, and thus &#39;trial and error&#39; while keeping an undisturbed original as reference.</div>

<div>&nbsp;</div>

<div>hope that helps a little, hope I didn&#39;t miss steps ...&nbsp;<br/>
--------------------------------------------------------------------------------------------------</div>
</div>

<div>&nbsp;
<div>
<div name="quote" style="margin:10px 5px 5px 10px; padding: 10px 0 10px 10px; border-left:2px solid #C3D9E5; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<div name="quoted-content">
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin: 0.0px 0.0px 0.0px 0.8ex;border-left: 1.0px solid rgb(204,204,204);padding-left: 1.0ex;">
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin: 0.0px 0.0px 0.0px 0.8ex;border-left: 1.0px solid rgb(204,204,204);padding-left: 1.0ex;">
<div>
<div style="font-family: Verdana;font-size: 12.0px;">
<div>
<div>
<div style="margin: 10.0px 5.0px 5.0px 10.0px;padding: 10.0px 0.0px 10.0px 10.0px;border-left: 2.0px solid rgb(195,217,229);">
<div>
<div>
<div>&nbsp;</div>
</div>
_______________________________________________ gnumeric-list mailing list <a href="mailto:[email protected]" onclick="parent.window.location.href=&#39;mailto:[email protected]&#39;; return false;" target="_blank">[email protected]</a> <a href="https://mail.gnome.org/mailman/listinfo/gnumeric-list" target="_blank">https://mail.gnome.org/mailman/listinfo/gnumeric-list</a></div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</div></div></body></html>

--===============7814937242860863843==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
gnumeric-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/gnumeric-list

--===============7814937242860863843==--