|     Inicio    |   |         |  |   FOROS      |  |      |      
   Elastix - VoIP B4A (Basic4Android) App inventor 2 PHP - MySQL
  Estación meteorológica B4J (Basic4Java) ADB Shell - Android Arduino
  Raspberry Pi Visual Basic Script (VBS) FireBase (BD autoactualizable) NodeMCU como Arduino
  AutoIt (Programación) Visual Basic Cosas de Windows Webs interesantes
Translate:
Búsqueda en este sitio:


.

Autoit en español
Aplicaciones con Autoit - Juan Antonio Villalpando

-- Tutorial de iniciación a Autoit --

Volver al índice del tutorial

____________________________

28.- Fases de la luna.

- Conociendo el algoritmo para calcular las fases de la luna, vamos a adaptarlo a AutoIt.

__________________________

- Ejecutamos Koda para crear el formulario.

- El dibujo de la imagen lo tomamos desde la Propiedad Picture.

- Es conveniente que el dibujo se encuentre en la misma carpeta que el código.

Código completo: los componentes y el algoritmo.

#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

 

- La convertimos en autoejecutable mediante Aut2Exe, aqui está: fase_luna.exe

_________________
- Propuesta.

-

- Mi correo:
juana1991@yahoo.com
- KIO4.COM - Política de cookies. Textos e imágenes propiedad del autor:
© Juan A. Villalpando
No se permite la copia de información ni imágenes.
Usamos cookies propias y de terceros que entre otras cosas recogen datos sobre sus hábitos de navegación y realizan análisis de uso de nuestro sitio.
Si continúa navegando consideramos que acepta su uso. Acepto    Más información