Ask Your Question

How to use math functions in the Calc Basic? [closed]

asked 2016-07-19 18:15:03 +0100

Adobe gravatar image

updated 2016-07-19 18:17:44 +0100

The documentations shows how to implement a basic VOL function:

Function VOL(a, b, c)
VOL = a*b*c
End Function

So that I can write


in a spreadsheet and get 6.

I want to write arctan which would return result in degrees instead of radians:

Function ARCTAN(rad)
ARCTAN = ATAN(rad)*180/PI()
End Function

and call it as, e.g.:


This doesn't work: Calc complains:

Sub-procedure or function procedure not defined

Can you help me to write this function?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2020-09-09 14:32:19.968150

2 Answers

Sort by » oldest newest most voted

answered 2016-07-19 20:49:26 +0100

Regina gravatar image

In this special case, you can use the internal functions of Basic. For a list of these functions see Alphabetic List of Functions, Statements and Operators in section Command Reference in tab Contents of the Help.

Your function might read

function ARCTAN(rad as double) as double
   ARCTAN = atn(rad)*45.0/atn(1)
end function

You need 45.0/atn(1) instead of 180.0/PI(), because PI() is not available as Basic-internal function.

edit flag offensive delete link more


PI() is not available but Pi works: ARCTAN = atn(rad) * 180 / Pi. Thanks!

Adobe gravatar imageAdobe ( 2016-07-19 22:50:53 +0100 )edit

Here's a list of most used math functions: atn/sin/cos/tan/exp/log/sqr/abs plus a constant Pi. Source.

Adobe gravatar imageAdobe ( 2016-07-19 23:16:55 +0100 )edit

Original function does work in LO v5.1.3.2 the only difference from original question being atn() vs ATAN() and this thanks to @Regina.

Also in this versions' off line Help, start with Content tab then Macros and Programming, Command Reference and finally Alphabetic List of Functions, Statements and Operators

Pi is actually used in the help example.

Changed "Answer' to "Comment" - posted just for Help reference.

Ratslinger gravatar imageRatslinger ( 2016-07-19 23:38:01 +0100 )edit

answered 2016-07-19 19:06:52 +0100

peterwt gravatar image

See posting here.

edit flag offensive delete link more


Thanks. The example you linked is more of a [currying])( though.

Adobe gravatar imageAdobe ( 2016-07-19 23:20:33 +0100 )edit

Question Tools

1 follower


Asked: 2016-07-19 18:15:03 +0100

Seen: 2,481 times

Last updated: Jul 19 '16