Macrocompiler and COS() SIN() TAN() and so on...

Public support forum for peer to peer support with related to the Visual Objects and Vulcan.NET products
Post Reply
omoser
Posts: 27
Joined: Tue Apr 19, 2016 8:14 am

Macrocompiler and COS() SIN() TAN() and so on...

Post by omoser »

Hi to all,
strange thing which i think worked fine in the past, but does not work anymore.

Simple thing, my appusers can create formulas to calculate with numeric fieldvalues.
e.g. <fieldname1> * 3 + <fieldname2> or more complex stuff like
<fieldname1> * sqrt( <fieldname2> ) i guess you see the principle.
with the most numeric functions of VO this works fine, eg.
SQRT(), ABS() INTEGER(), MIN() MAX() and even with ROUND() and IF() all works fine...

But not with COS() SIN() TAN() PI() LOG10(), COTAN(), COT()

For some calculations this is important to calculate lengths, and in the past it worked fine.

Migration the APP to x# i started to split it up in seperate libraries, to ease the migration.
that was the only change, but i do not know the exact last thing i changed, because it took a while
that this bug came up from my users.

Any help is appreciated, maybe a simple thing to configure i hope...
Thanks in advance and have a great sunday...

Oliver
omoser
Posts: 27
Joined: Tue Apr 19, 2016 8:14 am

Re: Macrocompiler and COS() SIN() TAN() and so on...

Post by omoser »

Addition: VO brings the GEncode:Error 33 - Missing parameter, which i guess is misleading, should be function not known, is the same as when i use any dummy-function name in the formula....
User avatar
Chris
Posts: 4936
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Re: Macrocompiler and COS() SIN() TAN() and so on...

Post by Chris »

Hi Oliver,

Indeed, in VO it is not possible to use strongly typed functions in macros, unless it is explicitly stated in the documentation that you can. For example, for Sqrt() and Min(), the docs does say that those functions can be used in macro expressions, even though they are strongly typed, but there's no such mention for Sin() and Log(). Not sure why some can and some can't, but the same problem exists also in user defined strongly typed functions, you can't use any such function in a macro expression IN VO as far as I know.

In X# there's no such limitation, you can use such functions without problems in macro expressions.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
omoser
Posts: 27
Joined: Tue Apr 19, 2016 8:14 am

Re: Macrocompiler and COS() SIN() TAN() and so on...

Post by omoser »

Hi Chris,
i read something about this, and so i had the great idea to write a kind of "wrapper function" like

function _cos( ngrad)
local nRad as float
nRad := nGrad / (180 / pi )
return cos( nRad )

So i converted the user input cos() to _cos() and i thought this could work,
or it did work in the past (??) but not now....

General Question:
Which rules do i have to follow to use my own functions() in the macro compiler?
Do i have to declare those functions somewhere, that the compiler knows about it?

maybe a compiler setting i changed in the migration project to x# which could
change the behaviour?

Thanks in advance for your support or ideas ...

BR Oliver

Chris wrote: Sun Nov 24, 2024 1:46 pm Hi Oliver,

Indeed, in VO it is not possible to use strongly typed functions in macros, unless it is explicitly stated in the documentation that you can. For example, for Sqrt() and Min(), the docs does say that those functions can be used in macro expressions, even though they are strongly typed, but there's no such mention for Sin() and Log(). Not sure why some can and some can't, but the same problem exists also in user defined strongly typed functions, you can't use any such function in a macro expression IN VO as far as I know.

In X# there's no such limitation, you can use such functions without problems in macro expressions.
User avatar
Chris
Posts: 4936
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Re: Macrocompiler and COS() SIN() TAN() and so on...

Post by Chris »

Hi Oliver,

Using your own functions should always work in VO, as long as they are of CLIPPER calling convention (not strongly typed). I just tried your _cos() function and it's working fine here. Maybe there is some other problem somewhere else in the code and it makes it look like there's a problem with macro compiling those functions?
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
omoser
Posts: 27
Joined: Tue Apr 19, 2016 8:14 am

Re: Macrocompiler and COS() SIN() TAN() and so on...

Post by omoser »

Hi Chris,
yes that is the strange thing!
It worked as you described in the past, i could use _cos() _SIN() and all other functions
i built as wrapper functions... but then is started to work on the migration to x#
as mentioned spilt the APP in LIBs, and all things worked fine, but out of nowwhere came this
feedback from a customer that those Trigonometric functions do not work anymore..

It drives me really crazy, there is no coding error, but something must be different...

I think about exporting all stuff, create a new project and import everything again.
Maybe some internal repo problems, binding during linking, i really dont know....
very strange and frustrating, i would prefer a mistake on my side :-=

BR Oliver
User avatar
robert
Posts: 4540
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Re: Macrocompiler and COS() SIN() TAN() and so on...

Post by robert »

Oliver,
Are you referring to VO or Vulcan.Net here?
If you're working with VO then you will have to make sure that the main app has code that calls these functions.
The VO Linker only links in functions that are referenced from the main app (and then the functions that are referenced by these functions etc).
I would recommend that you create a function in the main app (that you're never calling) that contains code that calls all of the relevant functions.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
ArneOrtlinghaus
Posts: 413
Joined: Tue Nov 10, 2015 7:48 am
Location: Italy

Re: Macrocompiler and COS() SIN() TAN() and so on...

Post by ArneOrtlinghaus »

A possible error could also be that the lib containing the functions has not been used before. Therefore it has not been loaded and so the functions are missing in the macro execution.

Arne
User avatar
Chris
Posts: 4936
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Re: Macrocompiler and COS() SIN() TAN() and so on...

Post by Chris »

Thanks Arne, that must be it! VO does not link functions that are not used directly in the code, so there needs to exist at least a dummy call to them somewhere in the code to force linking them. In X# there's no such problem, all functions are always available in the exe/dll and the compiler also adds initialization code to the Start() function that makes sure that all referenced libraries are loaded at startup.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
omoser
Posts: 27
Joined: Tue Apr 19, 2016 8:14 am

Re: Macrocompiler and COS() SIN() TAN() and so on...

Post by omoser »

Hi Arne, Chris and Robert!
Thank you for your ideas, that must be the solution,
because before those Functions were in the main,
but i splitted those into Libs for migration to X#,
so that really makes sense...

I am travelling today, but will check this evening!

Thank you very much for your help and support!

BR
Oliver
Post Reply