#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("Fase Lunar", 400, 300, 192, 124)
$Label1 = GUICtrlCreateLabel("Día", 32, 40, 31, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Input1 = GUICtrlCreateInput("", 72, 32, 33, 28, BitOR($ES_RIGHT,$ES_AUTOHSCROLL))
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("Mes", 128, 40, 37, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Input2 = GUICtrlCreateInput("", 176, 32, 33, 28, BitOR($ES_RIGHT,$ES_AUTOHSCROLL))
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Label3 = GUICtrlCreateLabel("Año", 232, 40, 36, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Input3 = GUICtrlCreateInput("", 280, 32, 49, 28, BitOR($ES_RIGHT,$ES_AUTOHSCROLL))
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Button1 = GUICtrlCreateButton("Pulsa para obtener la fase lunar", 80, 72, 201, 33)
$Label4 = GUICtrlCreateLabel("Fase lunar:", 24, 128, 94, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Label5 = GUICtrlCreateLabel("", 128, 128, 260, 40)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Pic1 = GUICtrlCreatePic("fase_lunar.gif", 32, 176, 305, 57, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUISetState(@SW_SHOW)
; Juan A. Villalpando - KIO4.COM
#EndRegion ### END Koda GUI section ###
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
; Cuando pulsa el botón realiza el cálculo.
Case $msg = $Button1
$dia = GUICtrlRead($Input1)
$mes = GUICtrlRead($Input2)
$anno = GUICtrlRead($Input3)
$c = 0
$e = 0
$jd = 0
$b = 0
If ($mes < 3) Then
$anno = $anno - 1
$mes = $mes + 12
EndIf
$mes = $mes + 1
$c = 365.25 * $anno
$e = 30.6 * $mes
$jd = $c + $e + $dia - 694039.09 ; jd es el tiempo total transcurrido
$jd = $jd / 29.5305882 ; divide por el ciclo lunar
$b = Int ($jd)
$jd = $jd - $b
$b = Round($jd * 8)
If ($b >= 8 ) Then $b = 0
Switch $b
Case 0
$fase = "Luna nueva"
Case 1
$fase = "Poco creciente"
Case 2
$fase = "Cuarto creciente"
Case 3
$fase = "Muy creciente"
Case 4
$fase = "Luna llena"
Case 5
$fase = "Poco menguante"
Case 6
$fase = "Cuarto menguante"
Case 7
$fase = "Muy menguante"
EndSwitch
GUICtrlSetData($Label5, $b & "-" & $fase)
EndSelect
WEnd
Exit
|