Re: Sunset, sunrise, twilight calculations in LC?

2014-08-27 Thread Charles E Buchwald
I would like to append this to what may be a record number of incorrect scripts on my part. Hugh pointed out in the forums that the floor of 5 is 5, and the ceiling of -5 is -5. These scripts might actually be correct, but I'm not guaranteeing anything at this point... My apologies for the noise

Re: Sunset, sunrise, twilight calculations in LC?

2014-08-27 Thread Charles E Buchwald
My apologies... I tested this when I first wrote it, and I thought I had everything covered. As others have pointed out, it requires a test for negative integers, so it should be: function Floor pValue if pValue is an integer OR pValue < 0 then return trunc(pValue) - 1 else return trunc(pV

Re: Sunset, sunrise, twilight calculations in LC?

2014-08-27 Thread Earthednet-wp
Beware: This function fails when the number is a negative integer. Bill > function Floor pValue > if pValue < 0 then return trunc(pValue) - 1 else return trunc(pValue) > end Floor William Prothero http://es.earthednet.org > On Aug 27, 2014, at 9:11 AM, Bob Sneidar wrote: > > Nicely done! I lov

Re: Sunset, sunrise, twilight calculations in LC?

2014-08-27 Thread Bob Sneidar
I’ve always thought that LC should include a roundUp and roundDown version of round(). Bob S ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http:

Re: Sunset, sunrise, twilight calculations in LC?

2014-08-27 Thread Bob Sneidar
Nicely done! I love this list!! Bob S On Aug 23, 2014, at 13:22 , Charles E Buchwald mailto:char...@buchwald.ca>> wrote: function Floor pValue if pValue < 0 then return trunc(pValue) - 1 else return trunc(pValue) end Floor I know this is trivial, but here's a ceiling function, just to kind o

Re: Sunset, sunrise, twilight calculations in LC?

2014-08-27 Thread Bob Sneidar
Just what I was thinking. Bob S On Aug 23, 2014, at 12:13 , Richmond mailto:richmondmathew...@gmail.com>> wrote: Well, presumably one way to do this would be to check if the number is positive or negative, and then, if it is negative multiply it by -1, round it, and then multiply it by -1 ag

Re: Sunset, sunrise, twilight calculations in LC?

2014-08-27 Thread Bob Sneidar
Yer a bit low. I’d add a pint. Bob On Aug 23, 2014, at 11:29 , Richmond mailto:richmondmathew...@gmail.com>> wrote: No: I was running 2 pints of beer :) Richmond. ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to

Re: Sunset, sunrise, twilight calculations in LC?

2014-08-27 Thread Bob Sneidar
floor = roundDown? Bob On Aug 23, 2014, at 09:13 , Earthednet-wp wrote: > Richmond, > Floor of a number is the largest integer that is less than or equal to the > number. For positive numbers, it would be trunc(myNumber) but for negative > numbers, floor(-4.34) would have to evaluate to -5.

Re: Sunset, sunrise, twilight calculations in LC?

2014-08-27 Thread Bob Sneidar
Not to throw a wrench in the works, but wasn’t there some discussion in the past about different versions of Julian dates? Which one is the more widely accepted? I suppose the question could be formed, which one does Microsoft use for Excel? :-) Bob S On Aug 23, 2014, at 13:27 , Mark Wieder

Re: Sunset, sunrise, twilight calculations in LC?

2014-08-27 Thread Bob Sneidar
Hey thanks for that Kay. I have a date conversion function that includes formats like sqlDate which the LC covert command does not support. This will be a nice addition. Bob S On Aug 23, 2014, at 01:28 , Kay C Lan mailto:lan.kc.macm...@gmail.com>> wrote: Nope, but this will help you calculat

Re: Sunset, sunrise, twilight calculations in LC?

2014-08-26 Thread William Prothero
Charles: Your function misses a special case. If the negative number is an integer, you wouldn’t want to subtract 1 from trunc(theNegativeNumber). Best, Bill On Aug 23, 2014, at 1:22 PM, Charles E Buchwald wrote: > Jacquie, I tested my script before I posted it, and it works for negative > inte

Re: Sunset, sunrise, twilight calculations in LC?

2014-08-23 Thread J. Landman Gay
On 8/23/2014, 3:25 PM, Mark Wieder wrote: The script implementations are fine, but it was way too easy to add these to the engine, so I just submitted a pull request for floor() and ceil(). Good on you. :) I've sometimes wondered why those two weren't in the engine, they're common in other lan

Re: Sunset, sunrise, twilight calculations in LC?

2014-08-23 Thread Mark Wieder
Charles- Saturday, August 23, 2014, 11:21:44 AM, you wrote: > Thanks. I have been using Sarah Reichelt's Date & Time Library, > which contains these functions by Mark Wieder. I actually didn't > realize they were under copyright, but I see that now. I didn't either. Or more probably I'd forgotte

Re: Sunset, sunrise, twilight calculations in LC?

2014-08-23 Thread Charles E Buchwald
Awesome, Mark. Even better than a feature request! On 23 Aug 2014, at 3:25 PM, Mark Wieder wrote: > All- > > The script implementations are fine, but it was way too easy to add > these to the engine, so I just submitted a pull request for floor() > and ceil(). > > -- > -Mark Wieder > ahsoftw.

Re: Sunset, sunrise, twilight calculations in LC?

2014-08-23 Thread Mark Wieder
All- The script implementations are fine, but it was way too easy to add these to the engine, so I just submitted a pull request for floor() and ceil(). -- -Mark Wieder ahsoftw...@gmail.com This communication may be unlawfully collected and stored by the National Security Agency (NSA) in secr

Re: Sunset, sunrise, twilight calculations in LC?

2014-08-23 Thread Charles E Buchwald
Jacquie, I tested my script before I posted it, and it works for negative integers. Colin, just for fun, I've consolidated mine to one line. Richmond, maybe you'd like to add "ceiling" to your sample stack? function Floor pValue if pValue < 0 then return trunc(pValue) - 1 else return trunc(pVal

Re: Sunset, sunrise, twilight calculations in LC?

2014-08-23 Thread Colin Holgate
Many languages equate booleans to 0 or 1. If LiveCode worked that way you could say: put trunk(n-(n<0)) ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferen

Solar Clock (was Re: Sunset, sunrise, twilight calculations in LC?)

2014-08-23 Thread FlexibleLearning.com
> I found this link. It might be easier to convert this code to LC. > http://williams.best.vwh.net/sunrise_sunset_algorithm.htm > Bill > > William Prothero > http://es.earthednet.org These algorithms have now been superceded by the NOAA algorithms http://www.esrl.noaa.gov/gmd/grad/solcalc. There

Re: Sunset, sunrise, twilight calculations in LC?

2014-08-23 Thread William Prothero
Folks: Try this: You have to be sure that if myNum is a perfect negative integer, floor(myNum) = myInteger while floor(-some non-integer) = trunc(myNum - 1) Colin’s version works too. on mouseUp put 1.55 into tNum put 1 into tCor put "case: "&tNum&" Correct value: "&tCor&", Calc Value:

Re: Sunset, sunrise, twilight calculations in LC?

2014-08-23 Thread Richmond
Go, get it Happy People :) http://forums.livecode.com/viewtopic.php?f=5&t=21404 Richmond. ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lis

Re: Sunset, sunrise, twilight calculations in LC?

2014-08-23 Thread Colin Holgate
You could do it in one line: put trunc(-14.2+10)-10 where the 10 part is a number bigger than anything you’re going to encounter in your app. ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to s

Re: Sunset, sunrise, twilight calculations in LC?

2014-08-23 Thread Richmond
On 23/08/14 22:03, J. Landman Gay wrote: On 8/23/2014, 1:28 PM, Richmond wrote: On 23/08/14 21:13, Charles E Buchwald wrote: So I'm thinking... function Floor pValue if pValue < 0 then return trunc(pValue) - 1 else return trunc(pValue) end Floor Quite unnecessary when 'round' does th

Re: Sunset, sunrise, twilight calculations in LC?

2014-08-23 Thread J. Landman Gay
On 8/23/2014, 1:28 PM, Richmond wrote: On 23/08/14 21:13, Charles E Buchwald wrote: So I'm thinking... function Floor pValue if pValue < 0 then return trunc(pValue) - 1 else return trunc(pValue) end Floor Quite unnecessary when 'round' does the trick without any homegrown functions.

Re: Sunset, sunrise, twilight calculations in LC?

2014-08-23 Thread Richmond
On 23/08/14 21:19, Colin Holgate wrote: You must be running LiveCode version -7. It shows -10 for me. On Aug 23, 2014, at 2:05 PM, Richmond wrote: put round(-9.8_ give us 10 Yo! Richmond. No: I was running 2 pints of beer :) Richmond. ___

Re: Sunset, sunrise, twilight calculations in LC?

2014-08-23 Thread Richmond
On 23/08/14 21:13, Charles E Buchwald wrote: So I'm thinking... function Floor pValue if pValue < 0 then return trunc(pValue) - 1 else return trunc(pValue) end Floor Quite unnecessary when 'round' does the trick without any homegrown functions. Richmond. ___

Re: Sunset, sunrise, twilight calculations in LC?

2014-08-23 Thread Charles E Buchwald
Kay, Thanks. I have been using Sarah Reichelt's Date & Time Library, which contains these functions by Mark Wieder. I actually didn't realize they were under copyright, but I see that now. It says something nice about LC that this code is 10 years old and still valid and valuable. - Charles --

Re: Sunset, sunrise, twilight calculations in LC?

2014-08-23 Thread Colin Holgate
You must be running LiveCode version -7. It shows -10 for me. On Aug 23, 2014, at 2:05 PM, Richmond wrote: > put round(-9.8_ > > give us 10 > > Yo! > > Richmond. ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to

Re: Sunset, sunrise, twilight calculations in LC?

2014-08-23 Thread Charles E Buchwald
So I'm thinking... function Floor pValue if pValue < 0 then return trunc(pValue) - 1 else return trunc(pValue) end Floor On 23 Aug 2014, at 1:05 PM, Richmond wrote: > On 23/08/14 20:44, J. Landman Gay wrote: >> On 8/23/2014, 11:20 AM, Richmond wrote: >>> That "floored me" :) Thanks for t

Re: Sunset, sunrise, twilight calculations in LC?

2014-08-23 Thread Richmond
On 23/08/14 20:44, J. Landman Gay wrote: On 8/23/2014, 11:20 AM, Richmond wrote: That "floored me" :) Thanks for the heads up! I just wrote this in the Message Box: put trunc(-9.8) and got '-9' The correct answer for "floor" would be -10. It's the largest integer that is less than the tes

Re: Sunset, sunrise, twilight calculations in LC?

2014-08-23 Thread J. Landman Gay
On 8/23/2014, 11:20 AM, Richmond wrote: That "floored me" :) Thanks for the heads up! I just wrote this in the Message Box: put trunc(-9.8) and got '-9' The correct answer for "floor" would be -10. It's the largest integer that is less than the test number. -- Jacqueline Landman Gay

Re: Sunset, sunrise, twilight calculations in LC?

2014-08-23 Thread Richmond
On 23/08/14 19:13, Earthednet-wp wrote: Richmond, Floor of a number is the largest integer that is less than or equal to the number. For positive numbers, it would be trunc(myNumber) but for negative numbers, floor(-4.34) would have to evaluate to -5. Probably trunc(myNum-1) would almost do it

Re: Sunset, sunrise, twilight calculations in LC?

2014-08-23 Thread Earthednet-wp
Richmond, Floor of a number is the largest integer that is less than or equal to the number. For positive numbers, it would be trunc(myNumber) but for negative numbers, floor(-4.34) would have to evaluate to -5. Probably trunc(myNum-1) would almost do it, but I'm not in LC to check all cases, e.

Re: Sunset, sunrise, twilight calculations in LC?

2014-08-23 Thread Richmond
On 23/08/14 17:44, Earthednet-wp wrote: I found this link. It might be easier to convert this code to LC. http://williams.best.vwh.net/sunrise_sunset_algorithm.htm Bill William Prothero http://es.earthednet.org That looks very good indeed: but I don't understand what 'floor' means. Richmond

Re: Sunset, sunrise, twilight calculations in LC?

2014-08-23 Thread Earthednet-wp
I found this link. It might be easier to convert this code to LC. http://williams.best.vwh.net/sunrise_sunset_algorithm.htm Bill William Prothero http://es.earthednet.org > On Aug 23, 2014, at 5:17 AM, Richmond wrote: > >> On 23/08/14 15:13, FlexibleLearning.com wrote: >> Yes. I have done this.

Re: Sunset, sunrise, twilight calculations in LC?

2014-08-23 Thread Richmond
On 23/08/14 15:13, FlexibleLearning.com wrote: Yes. I have done this. It is not a trivial exercise. It requires a lot of complex solar geometry calculations as well as Julian calcs. Go to http://www.esrl.noaa.gov/gmd/grad/solcalc, pick the "Solar Calculator", extract the javascript in the web pa

RE: Sunset, sunrise, twilight calculations in LC?

2014-08-23 Thread FlexibleLearning.com
Yes. I have done this. It is not a trivial exercise. It requires a lot of complex solar geometry calculations as well as Julian calcs. Go to http://www.esrl.noaa.gov/gmd/grad/solcalc, pick the "Solar Calculator", extract the javascript in the web page, then translate it to LC for use in your own w

Re: Sunset, sunrise, twilight calculations in LC?

2014-08-23 Thread Kay C Lan
Nope, but this will help you calculate the Julian Date Number, which you'll need: put the date into tDate convert tDate from date to dateItems if ((item 2 of tDate = 1) or (item 2 of tDate = 2)) then put 1 into tDay else put 0 into tDay end if put item 1 of tDate + 4

Re: Sunset, sunrise, twilight calculations in LC?

2014-08-22 Thread dunbarx
just for the thrill, well Craig Newman -Original Message- From: Charles E Buchwald To: How to use LiveCode Sent: Fri, Aug 22, 2014 7:46 pm Subject: Sunset, sunrise, twilight calculations in LC? Hi List People, Does anyone know of an LC version of sunrise/sunset and twi

Sunset, sunrise, twilight calculations in LC?

2014-08-22 Thread Charles E Buchwald
Hi List People, Does anyone know of an LC version of sunrise/sunset and twilight calculations? I found a couple of web based APIs, but I'd like it to work offline. I found this: http://en.wikipedia.org/wiki/Sunrise_equation ... but it's going to take me a while to translate that into LC, which is