Microsoft Small Basic

Program Listing: BDX206-1
GraphicsWindow.BackgroundColor = "Yellow"
GraphicsWindow.CanResize=1
GraphicsWindow.Width="685"
Controls.ButtonClicked = buttClicked
'urlBeep = "http://www.nonkit.com/smallbasic.files/se_sad08.wav"

marcador = 0
'Base de datos de array "respuestas" para las respuestas, aquí inicializada. modificada en sus valores con SetValue con el index de la pregunta acertada.
respuestas[1] = 0
respuestas[2] = 0
respuestas[3] = 0
respuestas[4] = 0
respuestas[5] = 0
respuestas[6] = 0
respuestas[7] = 0
respuestas[8] = 0
respuestas[9] = 0
respuestas[10] = 0
respuestas[11] = 0
respuestas[12] = 0
respuestas[13] = 0
respuestas[14] = 0
respuestas[15] = 0
respuestas[16] = 0
respuestas[17] = 0
respuestas[18] = 0
respuestas[19] = 0
respuestas[20] = 0
respuestas[21] = 0
respuestas[22] = 0
respuestas[23] = 0
respuestas[24] = 0
respuestas[25] = 0
respuestas[26] = 0
respuestas[27] = 0
respuestas[28] = 0
respuestas[29] = 0
respuestas[30] = 0
respuestas[31] = 0
respuestas[32] = 0
respuestas[33] = 0
respuestas[34] = 0
respuestas[35] = 0
respuestas[36] = 0
respuestas[37] = 0
respuestas[38] = 0
respuestas[39] = 0
respuestas[40] = 0
respuestas[41] = 0
respuestas[42] = 0
respuestas[43] = 0
respuestas[44] = 0
respuestas[45] = 0
respuestas[46] = 0
respuestas[47] = 0
respuestas[48] = 0
respuestas[49] = 0
respuestas[50] = 0
respuestas[51] = 0
respuestas[52] = 0
respuestas[53] = 0
respuestas[54] = 0
respuestas[55] = 0
respuestas[56] = 0
respuestas[57] = 0
respuestas[58] = 0
respuestas[59] = 0
respuestas[60] = 0
respuestas[61] = 0
respuestas[62] = 0
respuestas[63] = 0
respuestas[64] = 0
respuestas[65] = 0
respuestas[66] = 0
respuestas[67] = 0
respuestas[68] = 0
respuestas[69] = 0
respuestas[70] = 0
respuestas[71] = 0
respuestas[72] = 0
respuestas[73] = 0
respuestas[74] = 0
respuestas[75] = 0
respuestas[76] = 0
respuestas[77] = 0
respuestas[78] = 0
respuestas[79] = 0
respuestas[80] = 0
respuestas[81] = 0
respuestas[82] = 0
respuestas[83] = 0
respuestas[84] = 0
respuestas[85] = 0
respuestas[86] = 0
respuestas[87] = 0
respuestas[88] = 0
respuestas[89] = 0
respuestas[90] = 0
respuestas[91] = 0
respuestas[92] = 0
respuestas[93] = 0
respuestas[94] = 0
respuestas[95] = 0
respuestas[96] = 0
respuestas[97] = 0
respuestas[98] = 0
respuestas[99] = 0
respuestas[100] = 0
'Base de datos de preguntas
preguntas[1]["Jugador de fútbol"] = "LEO MESSI"
preguntas[2]["Jugador de fútbol"] = "CRISTIANO RONALDO"
preguntas[3]["Política"] = "MARIANO RAJOY"
preguntas[4]["Política"] = "PABLO IGLESIAS"
preguntas[5]["Concurso TV"] = "PASAPALABRA"
preguntas[6]["Concurso TV"] = "LA RULETA DE LA FORTUNA"
preguntas[7]["Política"] = "DONALD TRUMP"
preguntas[8]["Concurso TV"] = "SABER Y GANAR"
preguntas[9]["Baloncesto"] = "LEBRON JAMES"
preguntas[10]["Dicho"] = "EN ABRIL AGUAS MIL"
preguntas[11]["Actor/Actriz"] = "NICOLE KIDMAN"
preguntas[12]["Actor/Actriz"] = "JAVIER BARDEM"
preguntas[13]["Deporte"] = "BALONMANO"
preguntas[14]["Deporte"] = "HOCKEY PATINES"
preguntas[15]["Política"] = "CARLES PUIGDEMONT"
preguntas[16]["Dicho"] = "EN BOCA CERRADA NO ENTRAN MOSCAS"
preguntas[17]["Dicho"] = "GATOS CON GUANTES NO CAZA"
preguntas[18]["País"] = "FRANCIA"
preguntas[19]["País"] = "RUSIA"
preguntas[20]["Jugador de fútbol"] = "ANDRES INIESTA"
preguntas[21]["Jugador de fútbol"] = "ISCO"
preguntas[22]["Baloncesto"] = "PAU GASOL"
preguntas[23]["Científico/a"] = "MARIE CURIE"
preguntas[24]["Serie TV"] = "BREAKING BAD"
preguntas[25]["Serie TV"] = "NARCOS"
preguntas[26]["Festividad"] = "NAVIDAD"
preguntas[27]["Festividad"] = "SEMANA SANTA"
preguntas[28]["Equipo de fútbol"] = "MANCHESTER UNITED"
preguntas[29]["País"] = "ALEMANIA"
preguntas[30]["País"] = "ARGENTINA"
preguntas[31]["Equipo de fútbol"] = "PSG"
preguntas[32]["Equipo de fútbol"] = "REAL MADRID"
preguntas[33]["Política"] = "VLADIMIR PUTIN"
preguntas[34]["Enfermedad"] = "SIDA"
preguntas[35]["Dicho"] = "NO HAY MAL QUE POR BIEN NO VENGA"
preguntas[36]["Enfermedad"] = "GRIPE"
preguntas[37]["Científico/a"] = "LEONARDO DA VINCI"
preguntas[38]["Enfermedad"] = "PULMONIA"
preguntas[39]["País"] = "CANADA"
preguntas[40]["Nombre propio"] = "ROBERTO"
preguntas[41]["Nombre propio"] = "YOLANDA"
preguntas[42]["Estilo musical"] = "MUSICA CLASICA"
preguntas[43]["Enfermedad"] = "ESCLEROSIS MULTIPLE"
preguntas[44]["Científico/a"] = "ALBERT EINSTEIN"
preguntas[45]["Científico/a"] = "GALILEO GALILEI"
preguntas[46]["Enfermedad"] = "CANCER"
preguntas[47]["Deporte"] = "BALONCESTO"
preguntas[48]["Cantante"] = "SHAKIRA"
preguntas[49]["Cantante"] = "DAVID BISBAL"
preguntas[50]["Estilo musical"] = "RAP"
preguntas[51]["Estilo musical"] = "ROCK"
preguntas[52]["Nombre propio"] = "PURI"
preguntas[53]["Director cine"] = "STEVEN SPIELBERG"
preguntas[54]["País"] = "JAPON"
preguntas[55]["País"] = "ARABIA SAUDI"
preguntas[56]["Cantante"] = "ENRIQUE IGLESIAS"
preguntas[57]["Baloncesto"] = "STEPHEN CURRY"
preguntas[58]["Escritor"] = "TOLKIEN"
preguntas[59]["Escritor"] = "CERVANTES"
preguntas[60]["Vídeo juego"] = "CALL OF DUTY"
preguntas[61]["Vídeo juego"] = "ASSASSINS CREED"
preguntas[62]["Vídeo juego"] = "GRAND THEFT AUTO"
preguntas[63]["Mobiliario"] = "SILLON"
preguntas[64]["Mobiliario"] = "ESTANTERIA"
preguntas[65]["Color"] = "VERDE"
preguntas[66]["Color"] = "AMARILLO"
preguntas[67]["Deporte"] = "GOLF"
preguntas[68]["Marca coche"] = "MERCEDES"
preguntas[69]["Marca coche"] = "TOYOTA"
preguntas[70]["Marca deportiva"] = "NIKE"
preguntas[71]["Marca deportiva"] = "ADIDAS"
preguntas[72]["Festividad"] = "TODOS LOS SANTOS"
preguntas[73]["Gentilicio"] = "EXTREMEÑO"
preguntas[74]["Gentilicio"] = "ANDALUZ"
preguntas[75]["Mobiliario"] = "LAMPARA"
preguntas[76]["Youtuber"] = "RUBIUS"
preguntas[77]["Youtuber"] = "WILLYREX"
preguntas[78]["Youtuber"] = "VEGETTA"
preguntas[79]["Planta"] = "CACTUS"
preguntas[80]["Árbol"] = "PINO"
preguntas[81]["Árbol"] = "ROBLE"
preguntas[82]["Animal"] = "LEOPARDO"
preguntas[83]["Reptil"] = "COCODRILO"
preguntas[84]["Reptil"] = "SERPIENTE"
preguntas[85]["Animal"] = "ELEFANTE"
preguntas[86]["Órgano"] = "HIGADO"
preguntas[87]["Insecto"] = "ARAÑA"
preguntas[88]["Insecto"] = "MOSQUITO"
preguntas[89]["Insecto"] = "AVISPA"
preguntas[90]["Dicho"] = "SARNA CON GUSTO NO PICA"
preguntas[91]["Ciudad"] = "LOS ANGELES"
preguntas[92]["Ciudad"] = "CIUDAD REAL"
preguntas[93]["Ciudad"] = "PEKIN"
preguntas[94]["Moneda"] = "YEN"
preguntas[95]["Moneda"] = "EURO"
preguntas[96]["Moneda"] = "FRANCO SUIZO"
preguntas[97]["Ciudad"] = "SAN FRANCISCO"
preguntas[98]["Órgano"] = "CORAZON"
preguntas[99]["Animal"] = "PERRO"
preguntas[100]["Dicho"] = "MIENTRAS HAY VIDA HAY ESPERANZA"

rrr = 0 'variable que va sumando cada vez que una pregunta queda resuelta para averiguar algo más abajo cuando ya se acaba la partida si es igual al total de preguntas
pp = 0 'preguntas pendientes

num_preguntas = Array.GetItemCount(preguntas)
num_respuestas = Array.GetItemCount(respuestas)

inicio()

Sub inicio

If rrr = num_respuestas Then 'aquí cuento las respuestas 'dummies' que tengo más arriba y que se van rellenando con el valor de preguntas resueltas con "setvalue", para si ya se llega a ese número con la variable "rrr+1", el juego acaba"
GraphicsWindow.ShowMessage("Finalizó la partida. Ya se han mostrado todas las palabras/frases por adiviniar. Has acabado con " + marcador + " puntos. ¡Gracias por jugar a 'Saber y Ganar'!","Aviso")
Program.End()
Else
pp = num_preguntas - rrr 'aquí averiguo cuántas preguntas quedan pendientes por resolver y mostrar en la barra de título

If pp < 50 And pp > 25 Then
countdown = 45
ElseIf pp < 25 Or pp = 25 Then
countdown = 30
Else
countdown = 60
EndIf
Timer.Tick = Seconds ' triggered event subroutine to change the text displayed by shape object -> display
Timer.Interval = 1000 ' it's called-back every 1 second ( 1 second = 1000 milliseconds )


contador = 0
vocal = 0
a_azul = 0
b_azul = 0
c_azul = 0
d_azul = 0
e_azul = 0
f_azul = 0
g_azul = 0
h_azul = 0
i_azul = 0
j_azul = 0
k_azul = 0
l_azul = 0
m_azul = 0
n_azul = 0
ene_azul = 0
o_azul = 0
p_azul = 0
q_azul = 0
r_azul = 0
s_azul = 0
t_azul = 0
u_azul = 0
v_azul = 0
w_azul = 0
x_azul = 0
y_azul = 0
z_azul = 0

respuesta1 = "%"
respuesta2 = "%"
respuesta3 = "%"
respuesta4 = "%"
respuesta5 = "%"
respuesta6 = "%"
respuesta7 = "%"
respuesta8 = "%"
respuesta9 = "%"
respuesta10 = "%"
respuesta11 = "%"
respuesta12 = "%"
respuesta13 = "%"
respuesta14 = "%"
respuesta15 = "%"
respuesta16 = "%"

iii = 0
pregunta_sin_putoycoma = ""
tema = ""

'chequeo el array con las respuestas que se van metiendo para comparar con la BD de las preguntas y que no se repitan
repeticion_pregunta:
random = Math.GetRandomNumber(num_preguntas)
For cv = 1 To num_respuestas
If Array.GetValue (respuestas, cv) <> random Then
rand = random
Elseif Array.GetValue (respuestas, cv) = random Then
' GraphicsWindow.ShowMessage("detectado el " + random,"Aviso")
Goto repeticion_pregunta
EndIf
EndFor

'quito ";"
For i = 1 To Text.GetLength(preguntas[rand])
If Text.GetSubText(preguntas[rand], i, 1) = ";" Then 'si el carácter es ";"
For x = 1 To i - 1 'busca los caracteres antes de ";"
pregunta_sin_putoycoma = pregunta_sin_putoycoma + Text.GetSubText(preguntas[rand], x, 1) 'add that character to our new text
EndFor
pregunta_sin_putoycoma = pregunta_sin_putoycoma + "" 'reemplazo
For x = i + 1 To Text.GetLength(preguntas[rand]) 'sigo por el resto del texto
pregunta_sin_putoycoma = pregunta_sin_putoycoma + Text.GetSubText(preguntas[rand], x ,1) 'se añade el texto
EndFor
' TextToReplace = PreText
EndIf

EndFor
'Testeo: GraphicsWindow.DrawText (0,320,pregunta_sin_putoycoma) = OK

'Quito "=" y dejo el Tema
For ii = 1 To Text.GetLength(pregunta_sin_putoycoma)
If Text.GetSubText(pregunta_sin_putoycoma, ii, 1) = "=" Then 'si el carácter es "="
For xx = 1 To ii - 1 'busca los caracteres antes de "="
tema = tema + Text.GetSubText(pregunta_sin_putoycoma, xx, 1)
EndFor
EndIf
EndFor
'Testeo: GraphicsWindow.DrawText (0,330,tema) = OK

'Cojo del array la pregunta de manera visible y oculta
pregunta_hide = ""
pos = Text.GetIndexOf(pregunta_sin_putoycoma,"=") ' lo que busco para separar y quedarme con lo que hay tras el "="
if pos > 0 Then
pregunta_visible = Text.GetSubTextToEnd(pregunta_sin_putoycoma,pos+Text.GetLength("=")) 'el texto que está tras la búsqueda de texto realizada
EndIf
For xy = 1 To Text.GetLength(pregunta_visible)
If Text.GetSubText(pregunta_visible,xy, 1) = " " Then
pregunta_hide = pregunta_hide + " "
Else
pregunta_hide = pregunta_hide + "-"
EndIf
EndFor
'Testeo: TextWindow.WriteLine ("Pregunta visible: " + pregunta_visible + " - Pregunta oculta: " + pregunta_hide) = OK
lng_pregunta = Text.GetLength (pregunta_visible) 'averiguo cuántos caracteres tiene la pregunta para, en función de eso, dar a la pregunta más o menos puntos.
If lng_pregunta < 7 Then
contador = 14
ElseIf lng_pregunta > 10 Then
contador = 18
Else
contador = 16
EndIf

cuestionario()
EndIf
EndSub

Sub cuestionario

GraphicsWindow.Clear()
botones()

GraphicsWindow.FontSize = 12
GraphicsWindow.BrushColor = "Blue"
GraphicsWindow.DrawText (69,5,"BIENVENID@ A SABER y GANAR ver.1.0 - Roberto García Cáceres - 2018 - http://rgc.eu5.org")
GraphicsWindow.FontItalic = "true"
GraphicsWindow.BrushColor = "Black"
GraphicsWindow.FontSize = 11
GraphicsWindow.DrawText (18,30,"Cada letra introducida, inlcuida la 1ª vocal, reducirá 2 puntos el valor de la frase (según complejidad) a averiguar")
GraphicsWindow.DrawText (57,50,"Las siguientes vocales te descontarán 4 puntos. Según se avance, tienes 60'', 45'' o 30'' para resolver")
GraphicsWindow.BrushColor = "Red"
GraphicsWindow.FontItalic = "false"
GraphicsWindow.FontSize = 25
GraphicsWindow.DrawText (10, 90, "Tema: " + tema + " " + pregunta_hide)
GraphicsWindow.FontSize = 22
GraphicsWindow.DrawText (10, 130, "Puntos pregunta: " + contador)
GraphicsWindow.DrawText (10, 160, "Marcador total: " + marcador + " puntos")
GraphicsWindow.FontSize = 12
GraphicsWindow.BrushColor = "Blue"
GraphicsWindow.DrawText (232,400,"roberto.garcia.caceres@gmail.com")
GraphicsWindow.BrushColor = "Red"

EndSub

Sub cotejar_frase
respuesta_total_mayusculas = Text.ConvertToUpperCase (Controls.GetTextBoxText(respuesta_total))
If respuesta_total_mayusculas = pregunta_visible Then

pregunta_hide = pregunta_visible
marcador = marcador + contador
cuestionario ()
Timer.Pause()
Sound.PlayChime()
GraphicsWindow.ShowMessage("¡Genial! Has acertado, efectivamente era '" + pregunta_visible +"'.","Acierto")
Array.SetValue (respuestas,rand, rand) ' añado index de la pregunta al array de respuestas para su posterior comparación y que la pregunta no vuelva a salir
rrr = rrr + 1

inicio ()

Else
Timer.Pause()
GraphicsWindow.ShowMessage("Lamentablemente '" + respuesta_total_mayusculas + "' no es correcto.","Fallo")
Timer.Resume()
EndIf
EndSub


Sub cotejar_letra

l_acertada_before = 0 'Con "letra acertada" voy a comprobar si la letra introducida ha sido acertada, comparo los guiones antes de cotejar y los que quedan tras el cotejo (más abajo). Si hay uno de menos, es porque se ha acertado; si se mantiene el número de guiones, se ha fallado y emito un sonido de error.
For la = 1 To Text.GetLength(pregunta_hide)
If Text.GetSubText(pregunta_hide, la, 1) = "-" Then 'si el carácter es "-"
l_acertada_before = l_acertada_before + 1
EndIf
EndFor


iii = iii + 1
If iii = 1 Then
respuesta1 = respuesta
ElseIf iii = 2 Then
respuesta2 = respuesta
ElseIf iii = 3 Then
respuesta3 = respuesta
ElseIf iii = 4 Then
respuesta4 = respuesta
ElseIf iii = 5 Then
respuesta5 = respuesta
ElseIf iii = 6 Then
respuesta6 = respuesta
ElseIf iii = 7 Then
respuesta7 = respuesta
ElseIf iii = 8 Then
respuesta8 = respuesta
ElseIf iii = 9 Then
respuesta9 = respuesta
ElseIf iii = 10 Then
respuesta10 = respuesta
ElseIf iii = 11 Then
respuesta11 = respuesta
ElseIf iii = 12 Then
respuesta12 = respuesta
ElseIf iii = 13 Then
respuesta13 = respuesta
ElseIf iii = 14 Then
respuesta14 = respuesta
ElseIf iii = 15 Then
respuesta15 = respuesta
ElseIf iii = 16 Then
respuesta16 = respuesta
EndIf

If contador = 2 Then
Timer.Pause()
GraphicsWindow.ShowMessage("Solo te quedan 2 puntos, solo tiene sentido que resuelvas a través del botón 'Validar'.","Aviso")
Timer.Resume()
Else
pregunta_hide = ""
If respuesta = "A" Or respuesta = "E" Or respuesta = "I" Or respuesta = "O" Or respuesta = "U" Then
If vocal = 0 Then
contador = contador -2
vocal = 1
Else
contador = contador -4
EndIf
Else
contador = contador -2
EndIf



For w = 1 To Text.GetLength(pregunta_visible)

If Text.GetSubText(pregunta_visible, w, 1) = respuesta1 Then
pregunta_hide = pregunta_hide + respuesta1

ElseIf Text.GetSubText(pregunta_visible, w, 1) = respuesta2 Then
pregunta_hide = pregunta_hide + respuesta2

ElseIf Text.GetSubText(pregunta_visible, w, 1) = respuesta3 Then
pregunta_hide = pregunta_hide + respuesta3

ElseIf Text.GetSubText(pregunta_visible, w, 1) = respuesta4 Then
pregunta_hide = pregunta_hide + respuesta4

ElseIf Text.GetSubText(pregunta_visible, w, 1) = respuesta5 Then
pregunta_hide = pregunta_hide + respuesta5

ElseIf Text.GetSubText(pregunta_visible, w, 1) = respuesta6 Then
pregunta_hide = pregunta_hide + respuesta6

ElseIf Text.GetSubText(pregunta_visible, w, 1) = respuesta7 Then
pregunta_hide = pregunta_hide + respuesta7

ElseIf Text.GetSubText(pregunta_visible, w, 1) = respuesta8 Then
pregunta_hide = pregunta_hide + respuesta8

ElseIf Text.GetSubText(pregunta_visible, w, 1) = respuesta9 Then
pregunta_hide = pregunta_hide + respuesta9

ElseIf Text.GetSubText(pregunta_visible, w, 1) = respuesta10 Then
pregunta_hide = pregunta_hide + respuesta10

ElseIf Text.GetSubText(pregunta_visible, w, 1) = respuesta11 Then
pregunta_hide = pregunta_hide + respuesta11

ElseIf Text.GetSubText(pregunta_visible, w, 1) = respuesta12 Then
pregunta_hide = pregunta_hide + respuesta12

ElseIf Text.GetSubText(pregunta_visible, w, 1) = respuesta13 Then
pregunta_hide = pregunta_hide + respuesta13

ElseIf Text.GetSubText(pregunta_visible, w, 1) = respuesta14 Then
pregunta_hide = pregunta_hide + respuesta14

ElseIf Text.GetSubText(pregunta_visible, w, 1) = respuesta15 Then
pregunta_hide = pregunta_hide + respuesta15

ElseIf Text.GetSubText(pregunta_visible, w, 1) = respuesta16 Then
pregunta_hide = pregunta_hide + respuesta16


Else

If Text.GetSubText(pregunta_visible, w, 1) = " " Then
pregunta_hide = (pregunta_hide + " ")
Else
pregunta_hide = pregunta_hide + "-"

EndIf
EndIf
EndFor
guion = "no"
For bmw = 1 To Text.GetLength(pregunta_hide)
If Text.GetSubText(pregunta_hide, bmw, 1) = "-" Then
guion = "si"

EndIf
EndFor

l_acertada_after = 0 'Comparando para saber si la letra era acertada o no, y si no lo era, emito sonido de fallo
For lac = 1 To Text.GetLength(pregunta_hide)
If Text.GetSubText(pregunta_hide, lac, 1) = "-" Then 'si el carácter es "-"
l_acertada_after = l_acertada_after + 1
EndIf
EndFor


If l_acertada_after = l_acertada_before Then
Sound.PlayClickAndWait()
'Sound.PlayAndWait(urlBeep)'Al fallar, emito un beep
EndIf

If guion = "no" Then
pregunta_hide = pregunta_visible
marcador = marcador + contador

cuestionario ()
Timer.Pause()
Sound.PlayChime()
GraphicsWindow.ShowMessage("¡Genial! Has acertado, efectivamente era '" + pregunta_visible +"'.","Acierto")
Array.SetValue (respuestas,rand, rand) ' añado index de la pregunta al array de respuestas para su posterior comparación y que la pregunta no vuelva a salir
rrr = rrr + 1
inicio()

Else
cuestionario()
EndIf
EndIf
EndSub

Sub buttClicked
lastButton = Controls.LastClickedButton
If lastButton = AButton Then
respuesta = "A"
a_azul = 1
cotejar_letra()
Elseif lastButton = BButton Then
respuesta = "B"
b_azul = 1
cotejar_letra()
Elseif lastButton = CButton Then
respuesta = "C"
c_azul = 1
cotejar_letra()
Elseif lastButton = DButton Then
respuesta = "D"
d_azul = 1
cotejar_letra()
Elseif lastButton = EButton Then
respuesta = "E"
e_azul = 1
cotejar_letra()
Elseif lastButton = FButton Then
respuesta = "F"
f_azul = 1
cotejar_letra()
Elseif lastButton = GButton Then
respuesta = "G"
g_azul = 1
cotejar_letra()
Elseif lastButton = HButton Then
respuesta = "H"
h_azul = 1
cotejar_letra()
Elseif lastButton = IButton Then
respuesta = "I"
i_azul = 1
cotejar_letra()
Elseif lastButton = JButton Then
respuesta = "J"
j_azul = 1
cotejar_letra()
Elseif lastButton = KButton Then
respuesta = "K"
k_azul = 1
cotejar_letra()
Elseif lastButton = LButton Then
respuesta = "L"
l_azul = 1
cotejar_letra()
Elseif lastButton = MButton Then
respuesta = "M"
m_azul = 1
cotejar_letra()
Elseif lastButton = NButton Then
respuesta = "N"
n_azul = 1
cotejar_letra()
Elseif lastButton = ENEButton Then
respuesta = "Ñ"
ene_azul = 1
cotejar_letra()
Elseif lastButton = OButton Then
respuesta = "O"
o_azul = 1
cotejar_letra()
Elseif lastButton = PButton Then
respuesta = "P"
p_azul = 1
cotejar_letra()
Elseif lastButton = QButton Then
respuesta = "Q"
q_azul = 1
cotejar_letra()
Elseif lastButton = RButton Then
respuesta = "R"
r_azul = 1
cotejar_letra()
Elseif lastButton = SButton Then
respuesta = "S"
s_azul = 1
cotejar_letra()
Elseif lastButton = TButton Then
respuesta = "T"
t_azul = 1
cotejar_letra()
Elseif lastButton = UButton Then
respuesta = "U"
u_azul = 1
cotejar_letra()
Elseif lastButton = VButton Then
respuesta = "V"
v_azul = 1
cotejar_letra()
Elseif lastButton = WButton Then
respuesta = "W"
w_azul = 1
cotejar_letra()
Elseif lastButton = XButton Then
respuesta = "X"
x_azul = 1
cotejar_letra()
Elseif lastButton = YButton Then
respuesta = "Y"
y_azul = 1
cotejar_letra()
Elseif lastButton = ZButton Then
respuesta = "Z"
z_azul = 1
cotejar_letra()
Elseif lastButton = closeButton Then
Program.End()
Elseif lastButton = nextButton Then
contador = 0
marcador = marcador + contador
inicio()

Elseif lastButton = validarButton Then
If Controls.GetTextBoxText(respuesta_total) = "" Or Controls.GetTextBoxText(respuesta_total) = " " Or Text.GetLength (Controls.GetTextBoxText(respuesta_total)) < 3 Then
Timer.Pause()
GraphicsWindow.ShowMessage("No se ha rellenado correctamente la palabra o frase a resolver.","Error")
Timer.Resume()
Else
cotejar_frase()
Endif

EndIf



EndSub


Sub botones
GraphicsWindow.FontBold = "true"
GraphicsWindow.BrushColor = "Red"

If a_azul = 1 Then
GraphicsWindow.BrushColor = "Blue"
AButton = Controls.AddButton ("A", 5, 200)
Else
GraphicsWindow.BrushColor = "Red"
AButton = Controls.AddButton ("A", 5, 200)
EndIf
If b_azul = 1 Then
GraphicsWindow.BrushColor = "Blue"
BButton = Controls.AddButton ("B", 30, 200)
Else
GraphicsWindow.BrushColor = "Red"
BButton = Controls.AddButton ("B", 30, 200)
EndIf
If c_azul = 1 Then
GraphicsWindow.BrushColor = "Blue"
CButton = Controls.AddButton ("C", 55, 200)
Else
GraphicsWindow.BrushColor = "Red"
CButton = Controls.AddButton ("C", 55, 200)
EndIf
If d_azul = 1 Then
GraphicsWindow.BrushColor = "Blue"
DButton = Controls.AddButton ("D", 80, 200)
Else
GraphicsWindow.BrushColor = "Red"
DButton = Controls.AddButton ("D", 80, 200)
EndIf
If e_azul = 1 Then
GraphicsWindow.BrushColor = "Blue"
EButton = Controls.AddButton ("E", 105, 200)
Else
GraphicsWindow.BrushColor = "Red"
EButton = Controls.AddButton ("E", 105, 200)
EndIf
If f_azul = 1 Then
GraphicsWindow.BrushColor = "Blue"
FButton = Controls.AddButton ("F", 130, 200)
Else
GraphicsWindow.BrushColor = "Red"
FButton = Controls.AddButton ("F", 130, 200)
EndIf
If g_azul = 1 Then
GraphicsWindow.BrushColor = "Blue"
GButton = Controls.AddButton ("G", 155, 200)
Else
GraphicsWindow.BrushColor = "Red"
GButton = Controls.AddButton ("G", 155, 200)
EndIf
If h_azul = 1 Then
GraphicsWindow.BrushColor = "Blue"
HButton = Controls.AddButton ("H", 180, 200)
Else
GraphicsWindow.BrushColor = "Red"
HButton = Controls.AddButton ("H", 180, 200)
EndIf
If i_azul = 1 Then
GraphicsWindow.BrushColor = "Blue"
IButton = Controls.AddButton ("I", 205, 200)
Else
GraphicsWindow.BrushColor = "Red"
IButton = Controls.AddButton ("I", 205, 200)
EndIf
If j_azul = 1 Then
GraphicsWindow.BrushColor = "Blue"
JButton = Controls.AddButton ("J", 230, 200)
Else
GraphicsWindow.BrushColor = "Red"
JButton = Controls.AddButton ("J", 230, 200)
EndIf
If k_azul = 1 Then
GraphicsWindow.BrushColor = "Blue"
KButton = Controls.AddButton ("K", 255, 200)
Else
GraphicsWindow.BrushColor = "Red"
KButton = Controls.AddButton ("K", 255, 200)
EndIf
If l_azul = 1 Then
GraphicsWindow.BrushColor = "Blue"
LButton = Controls.AddButton ("L", 280, 200)
Else
GraphicsWindow.BrushColor = "Red"
LButton = Controls.AddButton ("L", 280, 200)
EndIf
If m_azul = 1 Then
GraphicsWindow.BrushColor = "Blue"
MButton = Controls.AddButton ("M", 305, 200)
Else
GraphicsWindow.BrushColor = "Red"
MButton = Controls.AddButton ("M", 305, 200)
EndIf
If n_azul = 1 Then
GraphicsWindow.BrushColor = "Blue"
NButton = Controls.AddButton ("N", 330, 200)
Else
GraphicsWindow.BrushColor = "Red"
NButton = Controls.AddButton ("N", 330, 200)
EndIf
If ene_azul = 1 Then
GraphicsWindow.BrushColor = "Blue"
ENEButton = Controls.AddButton ("Ñ", 355, 200)
Else
GraphicsWindow.BrushColor = "Red"
ENEButton = Controls.AddButton ("Ñ", 355, 200)
EndIf
If q_azul = 1 Then
GraphicsWindow.BrushColor = "Blue"
OButton = Controls.AddButton ("O", 380, 200)
Else
GraphicsWindow.BrushColor = "Red"
OButton = Controls.AddButton ("O", 380, 200)
EndIf
If p_azul = 1 Then
GraphicsWindow.BrushColor = "Blue"
PButton = Controls.AddButton ("P", 405, 200)
Else
GraphicsWindow.BrushColor = "Red"
PButton = Controls.AddButton ("P", 405, 200)
EndIf
If q_azul = 1 Then
GraphicsWindow.BrushColor = "Blue"
QButton = Controls.AddButton ("Q", 430, 200)
Else
GraphicsWindow.BrushColor = "Red"
QButton = Controls.AddButton ("Q", 430, 200)
EndIf
If r_azul = 1 Then
GraphicsWindow.BrushColor = "Blue"
RButton = Controls.AddButton ("R", 455, 200)
Else
GraphicsWindow.BrushColor = "Red"
RButton = Controls.AddButton ("R", 455, 200)
EndIf
If s_azul = 1 Then
GraphicsWindow.BrushColor = "Blue"
SButton = Controls.AddButton ("S", 480, 200)
Else
GraphicsWindow.BrushColor = "Red"
SButton = Controls.AddButton ("S", 480, 200)
EndIf
If t_azul = 1 Then
GraphicsWindow.BrushColor = "Blue"
TButton = Controls.AddButton ("T", 505, 200)
Else
GraphicsWindow.BrushColor = "Red"
TButton = Controls.AddButton ("T", 505, 200)
EndIf
If u_azul = 1 Then
GraphicsWindow.BrushColor = "Blue"
UButton = Controls.AddButton ("U", 530, 200)
Else
GraphicsWindow.BrushColor = "Red"
UButton = Controls.AddButton ("U", 530, 200)
EndIf
If v_azul = 1 Then
GraphicsWindow.BrushColor = "Blue"
VButton = Controls.AddButton ("V", 555, 200)
Else
GraphicsWindow.BrushColor = "Red"
VButton = Controls.AddButton ("V", 555, 200)
EndIf
If w_azul = 1 Then
GraphicsWindow.BrushColor = "Blue"
WButton = Controls.AddButton ("W", 580, 200)
Else
GraphicsWindow.BrushColor = "Red"
WButton = Controls.AddButton ("W", 580, 200)
EndIf
If x_azul = 1 Then
GraphicsWindow.BrushColor = "Blue"
XButton = Controls.AddButton ("X", 610, 200)
Else
GraphicsWindow.BrushColor = "Red"
XButton = Controls.AddButton ("X", 610, 200)
EndIf
If y_azul = 1 Then
GraphicsWindow.BrushColor = "Blue"
YButton = Controls.AddButton ("Y", 635, 200)
Else
GraphicsWindow.BrushColor = "Red"
YButton = Controls.AddButton ("Y", 635, 200)
EndIf
If z_azul = 1 Then
GraphicsWindow.BrushColor = "Blue"
ZButton = Controls.AddButton ("Z", 660, 200)
Else
GraphicsWindow.BrushColor = "Red"
ZButton = Controls.AddButton ("Z", 660, 200)
EndIf

GraphicsWindow.BrushColor = "Red"
GraphicsWindow.DrawText (5,245,"Resolver: ")
GraphicsWindow.BrushColor = "Brown"
validarButton = Controls.AddButton ("Validar", 230, 240)
respuesta_total = Controls.AddTextBox (65,240)
nextButton = Controls.AddButton ("Ir a otra palabra / frase", 264, 320)
closeButton = Controls.AddButton ("Salir de Saber y Ganar", 269, 360)

EndSub

Sub Seconds
If countdown > 0 Then
countdown = countdown - 1 ' 1 second less for countdown
ElseIf countdown = 0 Then
Timer.Pause()
GraphicsWindow.ShowMessage("Se agotó el minuto para resolver esta palabra/frase, 0 puntos. Ésta puede volver a aparecer.","Tiempo cumplido")
contador = 0
marcador = marcador + contador
inicio()
EndIf
GraphicsWindow.Title = "SABER y GANAR Ver. 1.0 - Tiempo restante para resolver: " + countdown + " segundo(s) - Preguntas restantes: " + pp

EndSub