[Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register]

Author Message
edward233
General User

Joined: 11 Nov 2004
Posts: 16

 Posted: Wed Dec 01, 2004 5:18 am    Post subject: Help with this user function Im having problems with this user function cant seem to get it working. Any help would be appriciated. FUNCTION jday(year, month As Integer, day As Integer, hour As Integer,min As Integer, sec As Double, Optional greg) As Double ' returns julian day number given date in gregorian calender (greg=1) ' or julian calendar (greg = 0). If greg ommited, then Gregorian is assumed. Dim a As Double Dim b As Integer 'a = 10000 * year' + 100 * month + day If (a < -47120101) Then MsgBox "Warning: date too early for algorithm" If (IsMissing(greg)) Then greg = 1 If (month <= 2) Then month = month + 12 Year = Year - 1 End If If (greg = 0) Then b = -2 + Fix((Year + 4716) / 4) - 1179 Else b = Fix(Year / 400) - Fix(Year / 100) + Fix(Year / 4) End If a = 365 * Year + 1720996.5 jday = a + b + Fix(30.6001 * (month + 1)) + day + (hour + min / 60 + sec / 3600) / 24 End FUNCTION Ed
r_vinoya
Super User

Joined: 03 Dec 2003
Posts: 619
Location: Somewhere in the Philippines

Posted: Wed Dec 01, 2004 5:35 pm    Post subject: Re: Help with this user function

 edward233 wrote: Im having problems with this user function cant seem to get it working. Any help would be appriciated. FUNCTION jday(year, month As Integer, day As Integer, hour As Integer,min As Integer, sec As Double, Optional greg) As Double ' returns julian day number given date in gregorian calender (greg=1) ' or julian calendar (greg = 0). If greg ommited, then Gregorian is assumed. Dim a As Double Dim b As Integer 'a = 10000 * year' + 100 * month + day If (a < -47120101) Then MsgBox "Warning: date too early for algorithm" If (IsMissing(greg)) Then greg = 1 If (month <= 2) Then month = month + 12 Year = Year - 1 End If If (greg = 0) Then b = -2 + Fix((Year + 4716) / 4) - 1179 Else b = Fix(Year / 400) - Fix(Year / 100) + Fix(Year / 4) End If a = 365 * Year + 1720996.5 jday = a + b + Fix(30.6001 * (month + 1)) + day + (hour + min / 60 + sec / 3600) / 24 End FUNCTION Ed

I just want to ask some questions...
What do you mean by "...cant seem to get it working?"

Does the macro has run-time error or is it not calculating as you wanted it to?

Also as tips,
1) it is better if you don't use variables that may be a special command (I don't really am sure if day, month, year and hour are special commands).
2) When your query is regarding Macros, it is better to ask this in Macros and API forum.
_________________
# : - )
ooouser999
General User

Joined: 04 Jan 2006
Posts: 5

 Posted: Wed Jan 04, 2006 9:20 am    Post subject: Quirk in user defined functions I had a problem getting user defined functions when I had a text label that was the same as the user defined function name. For example: - put an integer in A2. - in cell C1 put '="FOO"' (no single quotes). - in Cell C2 put '=foo(a2)' (no single quotes). The user defined function code: Function FOO(x) FOO = x * 5 end Function This would seem to work, until I closed the document and re-open it. Then I would get an error, which was either a "#REF!" error or occasionally Err:509. OOo appears to have changed the function call in C2 to: ='FOO'(A2). If you delete the text in C1 and correct the function call in C2, all becomes well.
Villeroy
Super User

Joined: 04 Oct 2004
Posts: 10065
Location: Germany

 Posted: Wed Jan 04, 2006 10:42 am    Post subject: There is an option like "row/col-header auto-detection" in Tools>Options>Calc>Calculation. Your setup (label = function name) stumbles on this "feature". Turn it off.
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First
 All times are GMT - 8 Hours Page 1 of 1

 Jump to: Select a forum OpenOffice.org Forums----------------Setup and TroubleshootingOpenOffice.org WriterOpenOffice.org CalcOpenOffice.org ImpressOpenOffice.org DrawOpenOffice.org MathOpenOffice.org BaseOpenOffice.org Macros and APIOpenOffice.org Code Snippets Community Forums----------------General DiscussionSite Feedback
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum