![]() |
|
#11
|
|||
|
|||
|
Should even simple functions be added as a method? e.g. I have a function that calculates the modified Julian day that doesn't need to be passed any data. But should I pass it the data table anyway so it can write the result there?
Code:
MJD = function(self, data)
local tm = {}
tm = os.date('*t')
self.MJD = 367 * tm.year - math.floor(7 * (tm.year + math.floor((tm.month + 9) / 12)) / 4)
+ math.floor(275 * tm.month / 9) + tm.day + 1721013.5 - 2400000.5
end,
|
|
#12
|
||||
|
||||
|
I'd probably not put that in the class - it's more of a utility function and should just return the result. Either make it a local function in the same file (before the class definition), or put it in a separate file and use require to load that file.
I used to own a Friden Flexowriter back in the late 70s
__________________
--Rob Last edited by Rob H; November 9th, 2006 at 02:53 AM. |
|
#13
|
|||
|
|||
|
Why "before the class definition"? I know a function has to be defined before it's called, but doesn't that happen at G startup before any serial data is received?
|
|
#14
|
||||
|
||||
|
Because I suggested making it a local function ie
Code:
local function MJD()
__________________
--Rob |
![]() |
| Thread Tools | |
| Display Modes | |
|
|