JustinReno Posted March 26, 2008 Share Posted March 26, 2008 (edited) Well, it took me a while, but I finally figured this out. Its an age calculator!It gives you your current age, Months alive, Days alive, Hours alive, and how old you are in dog. *1All credit goes to Jardenix (JustinReno)Source: *2expandcollapse popup$BirthString = InputBox("Age", "Please enter your birthstring:" & @CRLF & "(Numical Month/Day/4 Digit Year)") MsgBox(0, _Month(), "Age: " & _Oldness() & @CRLF & "Months Alive: " & _MonthsAlive() & @CRLF & "Days Alive: " & _DaysAlive() & @CRLF & "Hours Alive: " & _HoursAlive() & @CRLF & _DogYears() & " dog years old.") Func _Month() Dim $Months[2][12] = [["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], ["31", "29", "31", "30", "31", "30", "31", "31", "30", "31", "30", "31"]] $Age = StringSplit($BirthString, "/") $MonthBorn = $Months[0][$Age[1] - 1] Return $MonthBorn EndFunc Func _Oldness() $Age = StringSplit($BirthString, "/") If $Age[1] > @MON Then $Oldness = (@YEAR - $Age[3]) - 1 If $Age[1] < @MON Then $Oldness = @YEAR - $Age[3] Return $Oldness EndFunc Func _MonthsAlive() $Age = StringSplit($BirthString, "/") $MonthsLeft = 12 - $Age[1] $MonthsAlive = $Age[3] / 12 - $MonthsLeft Return Floor($MonthsAlive) - 1 EndFunc Func _DaysAlive() $MonthsAlive = _MonthsAlive() $DaysAlive = $MonthsAlive * 365 - 9993 Return $DaysAlive EndFunc Func _HoursAlive() $DaysAlive = _DaysAlive() $HoursAlive = $DaysAlive * 24 + 9993 Return $HoursAlive EndFunc Func _DogYears() $Age = StringSplit($BirthString, "/") $DogYears = (@YEAR - $Age[3]) / 7 Return $DogYears EndFuncEdit: Made how old you are in years 100% accurate.Please leave a comment!*1: The numbers returned are estimated and not exact.*2: The magic number 9993 makes the Days/Hours alive more accurate. Edited March 26, 2008 by Jardenix Link to comment Share on other sites More sharing options...
monoceres Posted March 26, 2008 Share Posted March 26, 2008 Got this error: C:\Users\Andreas\Desktop\dogyear.au3 (8) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $MonthBorn = $Months[0][$Age[1] - 1] $MonthBorn = ^ ERROR when inputed my age (05231990) Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
JustinReno Posted March 26, 2008 Author Share Posted March 26, 2008 (edited) This is how you put you birthday into the inputbox: (Numical Month/Day/4 Digit Year) Example: 12/15/1973 Remember "/" Edited March 26, 2008 by Jardenix Link to comment Share on other sites More sharing options...
JellyFish666 Posted March 26, 2008 Share Posted March 26, 2008 How many weeks and estimated death day would make it better Link to comment Share on other sites More sharing options...
Paulie Posted March 26, 2008 Share Posted March 26, 2008 Add this! Tells what weekday you were born on! $Month= 3 $Day = 24 $Year = 1991 MsgBox(0, "", CalcWeekday($Month,$Day,$Year)) Func CalcWeekday($Month,$Day,$Year,$Cal=0) $a = Floor((14 - $month) / 12) $y = $year - $a $m = $month + 12*$a - 2 $gregorian = Mod($day + $y + Floor($y/4) - Floor($y/100) + Floor($y/400) + Floor((31*$m)/12),7);gregorian $julian = Mod(5 + $day + $y + Floor($y/4) + Floor((31*$m)/12),7);julian If $Cal = 0 Then $Num = Floor($gregorian) Else $Num =Floor($julian) EndIf Dim $Day[7] = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"] Return $Day[$Num] EndFunc Link to comment Share on other sites More sharing options...
JustinReno Posted March 26, 2008 Author Share Posted March 26, 2008 Cool Paulie! How did you figure that out?! Link to comment Share on other sites More sharing options...
JustinReno Posted March 26, 2008 Author Share Posted March 26, 2008 I could also do this: (Same as Paulie's function, but shorter..) Global $Days[7] = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] Global $Day = 18, $Year = 94 $V = Mod(Floor(($Day + 2 + (10 * $Year) / 8 + 10)), 7) MsgBox(0, "", $Days[$V]) Link to comment Share on other sites More sharing options...
Achilles Posted March 26, 2008 Share Posted March 26, 2008 I think something is wrong with this: 2.714... dog years old. And I'm 19... Aren't dog years roughly 7 per human year? My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
JustinReno Posted March 26, 2008 Author Share Posted March 26, 2008 No, its dog years in human form (If that makes sense). If the dog is 2.7 years old, it would be 19 years old in dog years. Link to comment Share on other sites More sharing options...
Triblade Posted March 26, 2008 Share Posted March 26, 2008 Fun script. Only one thing: Try to set your clock to your birthday and run the script again Func _Oldness() $Age = StringSplit($BirthString, "/") If $Age[1] > @MON Then $Oldness = (@YEAR - $Age[3]) - 1 If $Age[1] < @MON Then $Oldness = @YEAR - $Age[3] Return $Oldness EndFunc This piece of code does not calculate when your birthmonth = @MON, but only when larger or smaller. You could use this: (Although I'm not sure about the else statement's correctness) Func _Oldness() $Age = StringSplit($BirthString, "/") If $Age[1] > @MON Then $Oldness = (@YEAR - $Age[3]) - 1 ElseIf $Age[1] < @MON Then $Oldness = @YEAR - $Age[3] Else $Oldness = @YEAR - $Age[3] EndIf Return $Oldness EndFunc My active project(s): A-maze-ing generator (generates a maze) My archived project(s): Pong3 (Multi-pinger) Link to comment Share on other sites More sharing options...
JellyFish666 Posted March 26, 2008 Share Posted March 26, 2008 (edited) No, its dog years in human form (If that makes sense).If the dog is 2.7 years old, it would be 19 years old in dog years.I don't really understand that and also thought the dog script was off it is roughly 7 years per year of our life, the dog won't be 19 when you are 19. Edited March 26, 2008 by JellyFish666 Link to comment Share on other sites More sharing options...
LIMITER Posted March 26, 2008 Share Posted March 26, 2008 I corrected the dog years (check http://www.onlineconversion.com/dogyears.htm for the forumla)expandcollapse popup$BirthString = InputBox("Age", "Please enter your birthstring:" & @CRLF & "(Numical Month/Day/4 Digit Year)") MsgBox(0, _Month(), "Age: " & _Oldness() & @CRLF & "Months Alive: " & _MonthsAlive() & @CRLF & "Days Alive: " & _DaysAlive() & @CRLF & "Hours Alive: " & _HoursAlive() & @CRLF & _DogYears() & " dog years old." & @CRLF & "If you are a dog this is your age : " & _CorrectDogYears()) Func _Month() Dim $Months[2][12] = [["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], ["31", "29", "31", "30", "31", "30", "31", "31", "30", "31", "30", "31"]] $Age = StringSplit($BirthString, "/") $MonthBorn = $Months[0][$Age[1] - 1] Return $MonthBorn EndFunc Func _Oldness() $Age = StringSplit($BirthString, "/") If $Age[1] > @MON Then $Oldness = (@YEAR - $Age[3]) - 1 If $Age[1] < @MON Then $Oldness = @YEAR - $Age[3] Return $Oldness EndFunc Func _MonthsAlive() $Age = StringSplit($BirthString, "/") $MonthsLeft = 12 - $Age[1] $MonthsAlive = $Age[3] / 12 - $MonthsLeft Return Floor($MonthsAlive) - 1 EndFunc Func _DaysAlive() $MonthsAlive = _MonthsAlive() $DaysAlive = $MonthsAlive * 365 - 9993 Return $DaysAlive EndFunc Func _HoursAlive() $DaysAlive = _DaysAlive() $HoursAlive = $DaysAlive * 24 + 9993 Return $HoursAlive EndFunc Func _DogYears() ;~ $Age = StringSplit($BirthString, "/") ;~ $DogYears = (@YEAR - $Age[3]) / 7 ;~ Return $DogYears $a = _Oldness() $b = Number("10,500000000000000002625") Return $a / $b EndFunc Func _CorrectDogYears() $1 = 0 For $i = 1 To _Oldness() If $i <= 2 Then $1 += 1 * 10.5 ConsoleWrite("<2 = " & $1 & @CRLF) Else $1 += 1 * 4 ConsoleWrite(">2 = " & $1 & @CRLF) EndIf Next Return $1 EndFunc Link to comment Share on other sites More sharing options...
weaponx Posted March 26, 2008 Share Posted March 26, 2008 What the hell kind of UDF relies on global variables? You need to be passing the birthdate as a parameter.Also I'm going to say the same thing I tell everyone else.You cannnot perform math on dates in AutoIt, this is not PHP. See _DateDiff().I enter 1/1/2008 and here is what it shows:Age: -1Months Alive: 155Days Alive: 46582Hours Alive: 11279610 dog years oldAgain with 1/1/2007:Age: 0Months Alive: 155Days Alive: 46852Hours Alive: 11279610.142857142857143 dog years old Link to comment Share on other sites More sharing options...
JustinReno Posted March 26, 2008 Author Share Posted March 26, 2008 (edited) This is not a UDF WeaponX. Get over it. There are no Global variables in my script. The dog years function is correct, The function takes your birthdate, divides it by seven to get how old you are if you were a dog (In human years)(NOT Dog years.) Edited March 26, 2008 by Jardenix Link to comment Share on other sites More sharing options...
Achilles Posted March 26, 2008 Share Posted March 26, 2008 (edited) The dog years function is correct,The function takes your birthdate, divides it by seven to get how old you are if you were a dog (In human years)(NOT Dog years.)I think it would be much more applicable/understandable if you were just told you many dog years you've been alive rather than supposing you are a dog that's lived x amount of years and wondering how many human years you've lived. Just my opinion though... Edited March 26, 2008 by Achilles My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
weaponx Posted March 26, 2008 Share Posted March 26, 2008 This is not a UDF WeaponX. Get over it. There are no Global variables in my script. The dog years function is correct,The function takes your birthdate, divides it by seven to get how old you are if you were a dog (In human years)(NOT Dog years.)Dude. You define $BirthString using InputBox() and it is not passed to any of your functions, therefore it is Global. I am not trying to give you a hard time, its just proper coding. Link to comment Share on other sites More sharing options...
Hellooopsforgotsendcommand Posted November 22, 2009 Share Posted November 22, 2009 Hey you , I dont want to know all those details about my age. I am trying to forget it. Link to comment Share on other sites More sharing options...
Developers Jos Posted November 22, 2009 Developers Share Posted November 22, 2009 Hey you , I dont want to know all those details about my age. I am trying to forget it.Seriously, stop resurrecting posts that are a couple of years old with BS comments like this!Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now