Aw: RE: Re: simple? c-coding / gnumeric coding style question ...



hello @Andreas

> You cannot call Gnumeric functions from Goffice

yes, i know, i understand and accept, but that's not what i want to do,

i want to call a gnumeric function from gnumeric, specifically 'gnumeric_rounddown' and 'gnumeric_roundup' from 'gnumeric_round',

best regards,

b.
 
Gesendet: Dienstag, 07. September 2021 um 17:29 Uhr
Von: "aguelzow" <aguelzow pyrshep ca>
An: "newbie nullzwei" <newbie-02 gmx de>, gebser mousecar com, "Gnumeric Forum" <gnumeric-list gnome org>
Betreff: RE: Aw: Re: simple? c-coding / gnumeric coding style question ...
Goffice and Gnumeric are two separate pieces of software. Goffice is a library. You cannot call Gnumeric functions from Goffice.
Andreas
 
 
 
Sent from my Galaxy
 
 
-------- Original message --------
From: newbie nullzwei via gnumeric-list <gnumeric-list gnome org>
Date: 2021-09-07 08:50 (GMT-07:00)
To: gebser mousecar com, Gnumeric Forum <gnumeric-list gnome org>
Subject: Aw: Re: simple? c-coding / gnumeric coding style question ...
 
 
hello @kf,

thanks for your input, but that - 'types' - is just an area where gnumeric is 'somewhat special' and not yet understood by me. from GnmValue, GnmFuncEvalInfo, *ei, GnmExprConstPtr, gnm_floats, doubles, handing over to goffice, how and when to use 'long's etc. ... i just know what a double is. and i haven't yet found a 'programmers handbook for gnumeric' except 'look how it's done and do it the same way'. (and i'm not sure whether i'd have the time to read or capa to understand if i could get such).

thus i'm restricted to ask the question as i did:

which would be 'the gnumeric way' to call one 'gnumeric function' from within another? simple example: from inside 'gnumeric_round' call 'gnumeric_rounddown' with the same arguments gnumeric round is calculating with, assign the result to a variable and thus be able to compare that with the result calculated by gnumeric_round before returnung it.

TIA for any help.

b.
Gesendet: Montag, 06. September 2021 um 18:48 Uhr
Von: "kf" <gebser mousecar com>
An: gnumeric-list gnome org
Betreff: Re: simple? c-coding / gnumeric coding style question ...
On 9/5/21 1:18 PM, newbie nullzwei via gnumeric-list wrote:
>
> hello @all,
>
> i'm not a coder but trying to adapt some routines for small improvements
> in rounding and am stuck at the following point:
>
> in functions.c i have the routine? function? 'gnumeric_rounddown',
>
> i'd like to call that function from inside the function 'gnumeric_round'
> and compare the results.
>
> i can call subroutines from goffice, but for those of gnumeric i have no
> idea.
>
> simple call failed with 'implicit declaration',
>
> putting a #define in numbers.h resulted in 'type conflicts' 'double' vs.
> 'GnmFuncEvalInfo',
>
> i could - but don't want to - copy the code from rounddown and paste it
> into round (with modifications),
>
> i could - but dont want to - move more functionality of rounddown into
> goffice (did such with oher calculations and now am able to call them as
> subroutines),
>
> but i think there should be a more elegant way,
>
> and one which complies with gnumeric coding style,
>
> if available a hint to a sample where such is done with other
> calculations could be enough, i'm weak in coding but somewhat better in
> copying and adapting ...
>
> TIA for any help or tip ...

Though I haven't looked at the code you're talking about, as a C
programmer of some years, I can say this:

To avoid the type mismatch error in many cases, look in the source code
where the function is located (routines in C are better known as
"functions). This is probably in one of the library, but you won't know
until you've looked. So grep for it, i.e.,

grep gnumeric_rounddown *.c

Well, it's possible to have C source files which don't have .c
extension. If that's the case for your code, adjust your search
accordingly.

This may find multiple instances, so look for the one which is a
function declaration. This function declaration will tell you what that
function's arguments are, something like

gnumeric_rounddown(int flag, double itemval, char *clabel)

(Of course all the text after "gnumeric_rounddown" will be different.)

Now, when you call the function "gnumeric_rounddown", it must have the
same data types as shown in that function declaration and in the same
order as the funtion declaration (though there can, in rare instances,
be exceptions, but you probably don't need to worry about that).

If that error you're having then doesn't go away, or if you're unclear
about what I've written, look in a basic C book, or do a web search, for
something like "calling functions".

If all that doesn't fix your basic problem, then I can't say.

hth,
ken
_______________________________________________
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]