[Solved] Why doesn't Calc show the macro result?
Posted: Mon Jan 29, 2024 5:37 am
I've written this macro (dectodms) which does work when I run it from inside the editor. But when I try to use it in a Doc A.ods cell (as a function), the cell remains blank. So #NAME or #VALUE do not appear in the cell, suggesting that Calc is recognizing the macro.
Yet I have another macro function (quadNE), which originally was in another spreadsheet (Doc B.ods), which does work as a cell function when I copy it into the Doc A.ods library.
I'm not a very experienced macro user, and I wouldn't be surprised if I'm doing something wrong, and it might be something really simple, but I've been reading OpenOffice Wiki pages, searching the forum and I can't figure this out. Any ideas would be really appreciated!
Code: Select all
REM ***** BASIC *****
Option Explicit
Function dmstodec(Optional a)
Dim seconds as Single, dmstodec as Single, absa as Single, absbuk as Single
Dim intega as Integer, minutes as Integer, intsign as Integer
If a<0 Then
intsign=-1
Else
intsign=1
End If
absa=abs(a)
intega=int(absa)
minutes=int((absa-intega)*100)
seconds=((absa-intega)*100-minutes)*100
absbuk=intega+(minutes/60)+(seconds/3600)
dmstodec=absbuk*intsign
End Function
Code: Select all
REM ***** BASIC *****
option EXPLICIT
function quadNE(Optional n,Optional e)
'Dim n
'Dim e
REM n and e will be cell references; dim command would reset them to 0
if n=0 then
Select Case e
case >0, 0
quadNE=1 REM [b][color=#4000FF]value of function is always returned from here[/color][/b]
case <0
quadNE=4
end Select
goto endF
elseif e=0 then
REM N<>0, E =0
Select Case n
case <0
quadNE=2
Case else
quadNE=1
end Select
goto endF
elseif e>0 then
select Case n
case >0
quadNE=1
case <0
quadNE=2
end Select
goto endF
elseif e<0 then
select Case n
case >0
quadNE=4
case <0
quadNE=3
end select
end if
endf:
end function