'dates001.bas 'Un programita que carga la fecha actual y usa un caledario (QCALENDAR) para definir otra fecha... 'A tiny app that uses QCALENDAR to pick a date, and that loads current date... 'I wrote this because I'm used to work with dates with a DD-MM-YYYY format, and RapidQ gave me a MM-DD-YYYY one... ' 'This code is part of my very first RapidQ application, I have just started learning, so don't expect anything amazing... 'I've just traslated the captions of the controls, but the names of the controls and subs are still in spanish... 'The code is also a little messy... ' 'You can use this code for whatever you want ' 'This file requires QCALENDAR.INC and APIDATE.BAS, by Pasquale Battistelli 'A few snippets of code (2 or 3) were borrowed from DAYS.BAS by Achilles B. Mina, but that file is not required to run this ' 'Código para RapidQ - Code for RapidQ 'Marzo de 2005 - March 2005 'Luis Valoyes - luisvaloyes@colombia.com 'Bogotá, Colombia 'The file with the calendar stuff... 'El archivo donde están las funciones del calendario $INCLUDE "QCALENDAR.INC" $INCLUDE "RAPIDQ.INC" 'The calendar window... 'La ventana del calendario... DIM VentanaCalendario AS QFORM 'The edit boxes where the dates must appear if everything goes OK... 'Los cuadros en los que deben aparecer las fechas si todo sale bien... DIM DiaHoy AS QEDIT, MesHoy AS QEDIT, AnhoHoy AS QEDIT, DiaOtro AS QEDIT, MesOtro AS QEDIT, AnhoOtro AS QEDIT VentanaCalendario.Center VentanaCalendario.Caption = "Calendar" VentanaCalendario.Width = 188 VentanaCalendario.Height = 236 VentanaCalendario.DelBorderIcons(1,2) 'The calendar... 'El calendario... DIM Calendario01 AS QCALENDAR Calendario01.Parent = VentanaCalendario Calendario01.init () 'Some SUBs to give a nice DD-MM-YYYY format to the dates... 'Algunas SUBs para darle el formato DD-MM-AAAA a las fechas... 'The first two of them give a nice format to the DD fields, according to the month... 'Las dos primeras le dan formato a la casilla de los días, según el mes... SUB DiaMes1a9 IF Calendario01.d < 10 THEN DiaOtro.Text = "0"+MID$(Calendario01.QDATE$,3,1) ELSEIF Calendario01.d >= 10 THEN DiaOtro.Text = MID$(Calendario01.QDATE$,3,2) END IF END SUB SUB DiaMes10a12 IF Calendario01.d < 10 THEN DiaOtro.Text = "0"+MID$(Calendario01.QDATE$,4,1) ELSEIF Calendario01.d >= 10 THEN DiaOtro.Text = MID$(Calendario01.QDATE$,4,2) END IF END SUB 'This one closes the calendar and assigns the date values to the corresponding fields 'Esta cierra la ventana del calendario, y asigna los valores de las fechas a las casillas correspondientes SUB CierraCalendario IF Calendario01.m < 10 THEN DiaMes1a9 ELSEIF Calendario01.m >= 10 THEN DiaMes10a12 END IF IF Calendario01.m < 10 THEN MesOtro.Text = "0"+LEFT$(Calendario01.QDATE$,1) ELSEIF Calendario01.m >= 10 THEN MesOtro.Text = LEFT$(Calendario01.QDATE$,2) END IF AnhoOtro.Text = RIGHT$(Calendario01.QDATE$,4) VentanaCalendario.Close END SUB 'This is the button that closes the calendar 'Este es el boton que cierra el calendario DIM BotonElegirFecha AS QBUTTON BotonElegirFecha.Parent = VentanaCalendario BotonElegirFecha.Caption = "Pick Date" BotonElegirFecha.Top = 184 BotonElegirFecha.Left = 16 BotonElegirFecha.Width = 147 BotonElegirFecha.Height = 24 BotonElegirFecha.Onclick = CierraCalendario 'La funcion que hace aparecer la ventana del calendario 'The SUB that opens the calendar window... wow it's impressive, isn't it? SUB AbreCalendario VentanaCalendario.Showmodal END SUB 'La ventana principal del programa 'The program's main window DIM VentanaGeneral AS QFORM VentanaGeneral.Center VentanaGeneral.Caption = "Dates" VentanaGeneral.Width = 256 VentanaGeneral.Height = 120 VentanaGeneral.DelBorderIcons(2) 'The labels 'Los títulos DIM TituloHoy AS QLABEL, TituloOtraFecha AS QLABEL TituloHoy.Parent = VentanaGeneral TituloHoy.Caption = "Today's date" TituloHoy.Top = 16 TituloHoy.Left = 16 TituloOtraFecha.Parent = VentanaGeneral TituloOtraFecha.Caption = "Another Date" TituloOtraFecha.Top = 64 TituloOtraFecha.Left = 16 'The date fields 'Las casillas de las fechas DiaHoy.Parent = VentanaGeneral DiaHoy.Top = 12 DiaHoy.Left = 120 DiaHoy.Width = 20 DiaHoy.MaxLength = 2 DiaHoy.Text = MID$(DATE$,4,2) DiaHoy.ReadOnly = True MesHoy.Parent = VentanaGeneral MesHoy.Top = 12 MesHoy.Left = 144 MesHoy.Width = 20 MesHoy.MaxLength = 2 MesHoy.Text = LEFT$(DATE$,2) MesHoy.ReadOnly = True AnhoHoy.Parent = VentanaGeneral AnhoHoy.Top = 12 AnhoHoy.Left = 168 AnhoHoy.Width = 36 AnhoHoy.MaxLength = 4 AnhoHoy.Text = RIGHT$(DATE$,4) AnhoHoy.ReadOnly = True DiaOtro.Parent = VentanaGeneral DiaOtro.Top = 60 DiaOtro.Left = 120 DiaOtro.Width = 20 DiaOtro.MaxLength = 2 MesOtro.Parent = VentanaGeneral MesOtro.Top = 60 MesOtro.Left = 144 MesOtro.Width = 20 MesOtro.MaxLength = 2 AnhoOtro.Parent = VentanaGeneral AnhoOtro.Top = 60 AnhoOtro.Left = 168 AnhoOtro.Width = 36 AnhoOtro.MaxLength = 4 'El botón que despliega el calendario... 'The button that displays the calendar... DIM BotonCalendario AS QBUTTON BotonCalendario.Parent = VentanaGeneral BotonCalendario.Caption = "Cal." BotonCalendario.Top = 60 BotonCalendario.Left = 208 BotonCalendario.Width = 32 BotonCalendario.Height = 21 BotonCalendario.Onclick = AbreCalendario 'Y el código que permite ver la ventana principal del programa... 'And the code that let us see the main window... VentanaGeneral.Showmodal