_Title "Qbasic 64" ' Many lines, created with help friend Bplus
Screen _NewImage(600, 600, 256)
_Delay .25
_ScreenMove 50, 50

'Moldura...
Line (0, 0)-(599, 599), 11, B 'Moldura inteira
Line (1, 1)-(598, 598), 11, B
Line (2, 2)-(597, 597), 11, B
Line (3, 3)-(596, 596), 11, B
Line (4, 4)-(595, 595), 11, B

Line (599, 43)-(2, 43), 11, B 'Linha Horizontal
Line (599, 44)-(2, 44), 11, B

'Mostra Data
d$ = Mid$(Date$, 1, 3)
c$ = Mid$(Date$, 4, 3)
e$ = Mid$(Date$, 7, 4)
f$ = c$ + d$ + e$

Color 11: Locate 2, 28: Print "* * * Mega Sena * * *"
Locate 2, 65: Print Time$
Locate 2, 4: Print f$
'--------------------------------------------------------------------------------
Dim nt(0 To 3000) As String
Dim cadastro As Long

_ControlChr Off

If _FileExists("mega.txt") Then
     Open "mega.txt" For Input As #1
     cadastro = LOF(1) \ 19
     For t = 1 To cadastro
          Line Input #1, nt$(t)
     Next
     Close
     Open "mega.txt" For Append As #1
Else
     Open "mega.txt" For Output As #1
End If
Do
     done = 1

     Color 30
     Locate 12, 3: Print "Concurso =>"; cadastro; "= "; nt$(cadastro)
     Locate 30, 3: Print "Pressione [ESC] para sair."
     Locate 4, 3: Print "N" + Chr$(163); "meros de concursos =>"; cadastro

     Locate 6, 14: Print "_____________"
     Locate 6, 3: Print "Dezenas => ";
     a$ = ExtendedInput$ 'code Mr. SMcNeill

     For r = 6 To 30
          Locate r, 2: Print Spc(72)
     Next

     For i = 1 To 12 Step 2
          x$ = x$ + Mid$(a$, i, 2) + " "
     Next

     x$ = _Trim$(x$)

     For i = 1 To cadastro
          If x$ = nt$(i) Then
               done = 0
               Color 48
               Locate 15, 25: Print "Contest:"; i; "exists!!!! "
               Locate 17, 29: Print ; nt$(i);
               Locate 18, 29: Print "================="
               Color 30
               Beep
               Exit For
          End If
     Next

     Locate 8, 3: Print "Dezenas => "; x$
     Locate 10, 3: Print "N£meros de digitos ="; Len(a$)


     If Len(a$) = 12 And done = 1 Then
          Print #1, x$
          Color 48
          Locate 15, 24: Print "Dezenas salvas com sucesso!!!"
          Locate 16, 24: Print "============================="
          Locate 18, 30: Print x$
          Locate 19, 30: Print "================="
          cadastro = cadastro + 1
          nt$(cadastro) = x$
          nt$ = x$
          Beep
     ElseIf Len(a$) > 12 Then
          Color 48
          Locate 20, 23: Print "Number of digits greater than 12 =>"; Len(a$)
          Locate 22, 30: Print ; a$
          Locate 23, 31: Print "============="
          Color 30
          Beep
     End If

     x$ = ""
     Scrn$ = InKey$
Loop Until Scrn$ = Chr$(27)
Close

Play "o3l32ceff+g"
Play "mfo4l64ceg>c"
Cls

OE20 = _LoadFont("century.ttf", 82)
_Font OE20
Color 11 ' &H200000FF
Locate 4, 90: Print " QBasic 64 "
Locate 5, 90: Print " -------------- "
_Delay 2
System

'--------------------------------------------------------------------------------

Function ExtendedInput$ 'code Mr. SMcNeill
     PCopy 0, 1
     A = _AutoDisplay: X = Pos(0): Y = CsrLin
     CP = 0: OldCP = 0 'Cursor Position
     _KeyClear
     Do
          PCopy 1, 0
          If _KeyDown(100307) Or _KeyDown(100308) Then AltDown = -1 Else AltDown = 0
          k = _KeyHit
          If AltDown Then
               Select Case k 'ignore all keypresses except ALT-number presses
                    Case 48 TO 57: AltWasDown = -1: alt$ = alt$ + Chr$(k)
               End Select
          Else
               Select Case k 'without alt, add any keypresses to our input
                    Case 8
                         oldin$ = in$
                         If CP > 0 Then OldCP = CP: CP = CP - 1
                         in$ = Left$(in$, CP) + Mid$(in$, CP + 2) 'backspace to erase input
                    Case 9
                         oldin$ = in$
                         in$ = Left$(in$, CP) + Space$(4) + Mid$(in$, CP + 1) 'four spaces for any TAB entered
                         OldCP = CP
                         CP = CP + 4
                    Case 32 TO 128
                         If _KeyDown(100305) Or _KeyDown(100306) Then
                              If k = 118 Or k = 86 Then
                                   oldin$ = in$
                                   in$ = Left$(in$, CP) + _Clipboard$ + Mid$(in$, CP + 1) 'ctrl-v paste
                                   'CTRL-V leaves cursor in position before the paste, without moving it after.
                                   'Feel free to modify that behavior here, if you want it to move to after the paste.
                                   CP = CP + Len(_Clipboard$)
                              End If
                              If k = 122 Or k = 90 Then Swap in$, oldin$: Swap OldCP, CP 'ctrl-z undo
                         Else
                              oldin$ = in$
                              in$ = Left$(in$, CP) + Chr$(k) + Mid$(in$, CP + 1) 'add input to our string
                              OldCP = CP
                              CP = CP + 1
                         End If
                    Case 18176 'Home
                         CP = 0
                    Case 20224 'End
                         CP = Len(in$)
                    Case 21248 'Delete
                         oldin$ = in$
                         in$ = Left$(in$, CP) + Mid$(in$, CP + 2)
                    Case 19200 'Left
                         CP = CP - 1
                         If CP < 0 Then CP = 0
                    Case 19712 'Right
                         CP = CP + 1
                         If CP > Len(in$) Then CP = Len(in$)
               End Select
          End If
          alt$ = Right$(alt$, 3)
          If AltWasDown = -1 And AltDown = 0 Then
               v = Val(alt$)
               If v >= 0 And v <= 255 Then in$ = in$ + Chr$(v)
               alt$ = "": AltWasDown = 0
          End If
          blink = (blink + 1) Mod 30
          Locate Y, X
          Print Left$(in$, CP);
          If blink \ 15 Then Print " "; Else Print "_";
          Print Mid$(in$, CP + 1)

          _Display
          _Limit 30
     Loop Until k = 13

     PCopy 1, 0
     Locate Y, X: Print in$
     ExtendedInput$ = in$
     If A Then _AutoDisplay
End Function




