Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - carloscordeiro

Pages: [1] 2 3 ... 7
1
Programs / Re: Line with repeated numbers
« on: August 04, 2021, 07:06:16 pm »
Quote
Your screen layouts look nice :)

Thanks for the compliment

This code is for querying the "mega.txt" database how many times there are 3 numbers, 4 numbers and 5 numbers.

He does just that.

Would using Select Case or ElseIf improve the code?

Would it decrease a little of the "if and for next"?

Insert this sequence in the code: 041112444557

http://loterias.caixa.gov.br/wps/portal/loterias/landing/megasena/

Site where I feed the txt database





2
Programs / Re: Line with repeated numbers
« on: August 04, 2021, 06:13:23 pm »
Bplus, I'm going to overdo the questions a bit.

Would you have an idea, to reduce the number of for next and if, in this other code?

You don't need to create other code, only if you have a better idea than mine.

Carlos
Code: QB64: [Select]
  1. _Title "Qbasic 64" ' Many lines, created with help friend Bplus
  2. Screen _NewImage(700, 740, 256)
  3. _Delay .25
  4.  
  5. 'Moldura...
  6. Line (0, 0)-(699, 719), 11, B 'Moldura inteira
  7. Line (1, 1)-(698, 718), 11, B
  8. Line (2, 2)-(697, 717), 11, B
  9. Line (3, 3)-(696, 716), 11, B
  10. Line (4, 4)-(695, 715), 11, B
  11.  
  12. Line (699, 43)-(2, 43), 11, B 'Linha Horizontal
  13. Line (699, 44)-(2, 44), 11, B
  14.  
  15. Line (336, 716)-(336, 44), 11, B 'Linha Vertical
  16. Line (335, 716)-(335, 44), 11, B
  17.  
  18. 'Mostra Data
  19. d$ = Mid$(Date$, 1, 3)
  20. c$ = Mid$(Date$, 4, 3)
  21. e$ = Mid$(Date$, 7, 4)
  22. f$ = c$ + d$ + e$
  23.  
  24. Color 11: Locate 2, 34: Print "* * * Mega Sena * * *"
  25. Locate 2, 4: Print f$: Color 7
  26.  
  27. '------------------------------------------------------------------------
  28. Dim nt(1 To 3000) As String
  29. Dim soma1(1 To 500) As String
  30. Dim soma2(1 To 500) As String
  31. Dim cor1(80) As _Integer64
  32. Dim seq(500) As _Integer64
  33. 'Dim re As _Integer64
  34. Dim file(1 To 50) As String
  35. '------------------------------------------------------------------------
  36.  
  37. Open "mega.txt" For Input As #1
  38. total = LOF(1) \ 19
  39. For t = 1 To total
  40.      Line Input #1, nt$(t)
  41.  
  42.  
  43. Color 30: Locate 4, 3: Print "N" + Chr$(163); "meros de concursos =>"; total
  44.      g = 0
  45.      h = 3
  46.      qu = 0
  47.      te = 0
  48.      Color 30
  49.      Locate 6, 14: Print "_____________"
  50.      Locate 6, 3: Print "Dezenas => ";
  51.      a$ = ExtendedInput$ 'code Mr. SMcNeill
  52.  
  53.      For i = 1 To 12 Step 2
  54.           x$ = x$ + Mid$(a$, i, 2) + " "
  55.      Next
  56.      Pes$ = _Trim$(x$)
  57.      If Len(Pes$) = 17 Then
  58.  
  59.           For S = 4 To 44
  60.                Locate S, 44: Print Spc(40)
  61.           Next S
  62.  
  63.           Color 78
  64.           Locate 8, 3: Print "Dezenas => "; Pes$; " ="; Len(Pes$)
  65.           Locate 9, 14: Print "================="
  66.  
  67.           For re = 1 To total
  68.                If h > 41 Then
  69.                     _KeyClear
  70.                     Color 13: Locate 44, 44: Print "Pressione Enter para continuar..."
  71.                     Color 7
  72.                     Do
  73.                          _Limit 30
  74.                     Loop Until InKey$ = Chr$(13)
  75.                     For S = 4 To 44
  76.                          Locate S, 44: Print Spc(40)
  77.                     Next S
  78.                     h = 3
  79.                End If
  80.  
  81.                h = h + 1
  82.                x = 49
  83.  
  84.                Color 15: Locate h, x - 5: Print Right$("0000" + LTrim$(Str$(re)), 4); " => "
  85.  
  86.                For i = 1 To 17 Step 3
  87.                     x = x + 3
  88.                     For r = 1 To 17 Step 3
  89.                          If Mid$(nt$(re), i, 2) = Mid$(Pes$, r, 2) Then
  90.                               g = g + 1
  91.                               cor1(g) = i
  92.                               Exit For
  93.                          Else
  94.                               Color 7: Locate h, x: Print Mid$(nt$(re), i, 2)
  95.                          End If
  96.                     Next r
  97.                Next i
  98.  
  99.                If g <= 2 Then
  100.                     Locate h, 44: Print Spc(29)
  101.                     h = h - 1
  102.                End If
  103.  
  104.                If g = 3 Then
  105.                     Color 12
  106.                     Locate h, x + 3: Print "=>";: Print " TERNO"
  107.                     For ag = 1 To 3
  108.                          te = te + 1
  109.                          Locate h, 51 + cor1(ag): Print Mid$(nt$(re), cor1(ag), 2)
  110.                          soma2(te) = Mid$(nt$(re), cor1(ag), 2)
  111.                     Next ag
  112.                     Color 7
  113.                End If
  114.  
  115.                If g = 4 Then
  116.                     Color 10
  117.                     Locate h, x + 3: Print "=>";: Print " QUADRA"
  118.                     For ag = 1 To 4
  119.                          qu = qu + 1
  120.                          Locate h, 51 + cor1(ag): Print Mid$(nt$(re), cor1(ag), 2)
  121.                          soma1$(qu) = Mid$(nt$(re), cor1(ag), 2)
  122.                     Next ag
  123.                     Color 7
  124.                End If
  125.  
  126.                If g = 5 Then
  127.                     Color 3
  128.                     Locate h, x + 3: Print "=>";: Print " QUINA"
  129.                     For ag = 1 To 5
  130.                          Locate h, 51 + cor1(ag): Print Mid$(nt$(re), cor1(ag), 2)
  131.                     Next ag
  132.                     Color 7
  133.                End If
  134.  
  135.                If g = 6 Then
  136.                     Color 14
  137.                     Locate h, x + 3:: Print "=>";: Print " SENA "
  138.                     For ag = 1 To 6
  139.                          Locate h, 51 + cor1(ag): Print Mid$(nt$(re), cor1(ag), 2)
  140.                     Next ag
  141.                     Color 7
  142.                End If
  143.                g = 0
  144.           Next
  145.           a = 12
  146.           For e = 10 To 22
  147.                Locate e, 2: Print Spc(35)
  148.           Next
  149.           '-------------------------------------------------------------------
  150.           For i = 1 To qu '- 1
  151.                t = 1
  152.                For j = i + 1 To qu
  153.                     If _Trim$(soma1(i)) = _Trim$(soma1(j)) And _Trim$(soma1(i)) <> "" Then
  154.                          t = t + 1
  155.                          soma1(j) = ""
  156.                     End If
  157.                Next
  158.                seq(i) = t
  159.                If soma1(i) <> "" Then
  160.                     a = a + 1
  161.                     Color 30
  162.                     Locate a, 3
  163.                     Print "Dez = ";
  164.                     Color 10
  165.                     Locate a, 8
  166.                     Print " "; soma1(i);
  167.                     Color 30
  168.                     Locate a, 12
  169.                     Print "="; seq(i)
  170.                End If
  171.           Next
  172.           '---------------------------------------------------------------------
  173.           a = 12
  174.           For i = 1 To te '- 1
  175.                t = 1
  176.                For j = i + 1 To te
  177.                     If _Trim$(soma2(i)) = _Trim$(soma2(j)) And _Trim$(soma2(i)) <> "" Then
  178.                          t = t + 1
  179.                          soma2(j) = ""
  180.                     End If
  181.                Next
  182.                seq(i) = t
  183.                If soma2(i) <> "" Then
  184.                     a = a + 1
  185.                     Color 30
  186.                     Locate a, 23
  187.                     Print "Dez = ";
  188.                     Color 12
  189.                     Locate a, 28
  190.                     Print " "; soma2(i);
  191.                     Color 30
  192.                     Locate a, 32
  193.                     Print "="; seq(i)
  194.                End If
  195.           Next
  196.           '-----------------------------------------------------------------------
  197.  
  198.      Else
  199.           Beep
  200.      End If
  201.      Color 13: Locate 44, 58: Print "Pressione [ESC] para sair..."
  202.      x$ = ""
  203.      Scrn$ = InKey$
  204. Loop Until Scrn$ = Chr$(27)
  205.  
  206. Play "o3l32ceff+g"
  207. Play "mfo4l64ceg>c"
  208.  
  209. OE20 = _LoadFont("century.ttf", 82)
  210. _Font OE20
  211. Color 11 ' &H200000FF
  212. Locate 4, 125: Print " QBasic 64 "
  213. Locate 5, 125: Print " -------------- "
  214.  
  215. '-------------------------------------------------------------------------------------
  216. Function ExtendedInput$ ' Mr. McNeill's extended entrance
  217.      PCopy 0, 1
  218.      A = _AutoDisplay: X = Pos(0): Y = CsrLin
  219.      CP = 0: OldCP = 0 'Cursor Position
  220.      _KeyClear
  221.      Do
  222.           PCopy 1, 0
  223.           If _KeyDown(100307) Or _KeyDown(100308) Then AltDown = -1 Else AltDown = 0
  224.           k = _KeyHit
  225.           If AltDown Then
  226.                Select Case k 'ignore all keypresses except ALT-number presses
  227.                     Case 48 TO 57: AltWasDown = -1: alt$ = alt$ + Chr$(k)
  228.                End Select
  229.           Else
  230.                Select Case k 'without alt, add any keypresses to our input
  231.                     Case 8
  232.                          oldin$ = in$
  233.                          If CP > 0 Then OldCP = CP: CP = CP - 1
  234.                          in$ = Left$(in$, CP) + Mid$(in$, CP + 2) 'backspace to erase input
  235.                     Case 9
  236.                          oldin$ = in$
  237.                          in$ = Left$(in$, CP) + Space$(4) + Mid$(in$, CP + 1) 'four spaces for any TAB entered
  238.                          OldCP = CP
  239.                          CP = CP + 4
  240.                     Case 32 TO 128
  241.                          If _KeyDown(100305) Or _KeyDown(100306) Then
  242.                               If k = 118 Or k = 86 Then
  243.                                    oldin$ = in$
  244.                                    in$ = Left$(in$, CP) + _Clipboard$ + Mid$(in$, CP + 1) 'ctrl-v paste
  245.                                    'CTRL-V leaves cursor in position before the paste, without moving it after.
  246.                                    'Feel free to modify that behavior here, if you want it to move to after the paste.
  247.                                    CP = CP + Len(_Clipboard$)
  248.                               End If
  249.                               If k = 122 Or k = 90 Then Swap in$, oldin$: Swap OldCP, CP 'ctrl-z undo
  250.                          Else
  251.                               oldin$ = in$
  252.                               in$ = Left$(in$, CP) + Chr$(k) + Mid$(in$, CP + 1) 'add input to our string
  253.                               OldCP = CP
  254.                               CP = CP + 1
  255.                          End If
  256.                     Case 18176 'Home
  257.                          CP = 0
  258.                     Case 20224 'End
  259.                          CP = Len(in$)
  260.                     Case 21248 'Delete
  261.                          oldin$ = in$
  262.                          in$ = Left$(in$, CP) + Mid$(in$, CP + 2)
  263.                     Case 19200 'Left
  264.                          CP = CP - 1
  265.                          If CP < 0 Then CP = 0
  266.                     Case 19712 'Right
  267.                          CP = CP + 1
  268.                          If CP > Len(in$) Then CP = Len(in$)
  269.                End Select
  270.           End If
  271.           alt$ = Right$(alt$, 3)
  272.           If AltWasDown = -1 And AltDown = 0 Then
  273.                v = Val(alt$)
  274.                If v >= 0 And v <= 255 Then in$ = in$ + Chr$(v)
  275.                alt$ = "": AltWasDown = 0
  276.           End If
  277.           blink = (blink + 1) Mod 30
  278.           Locate Y, X
  279.           Print Left$(in$, CP);
  280.           If blink \ 15 Then Print " "; Else Print "_";
  281.           Print Mid$(in$, CP + 1)
  282.  
  283.           _Display
  284.           _Limit 30
  285.      Loop Until k = 13
  286.  
  287.      PCopy 1, 0
  288.      Locate Y, X: Print in$
  289.      ExtendedInput$ = in$
  290.      If A Then _AutoDisplay
  291.  
  292.  

A lot for next and if

Code: QB64: [Select]
  1.                If g <= 2 Then
  2.                     Locate h, 44: Print Spc(29)
  3.                     h = h - 1
  4.                End If
  5.  
  6.                If g = 3 Then
  7.                     Color 12
  8.                     Locate h, x + 3: Print "=>";: Print " TERNO"
  9.                     For ag = 1 To 3
  10.                          te = te + 1
  11.                          Locate h, 51 + cor1(ag): Print Mid$(nt$(re), cor1(ag), 2)
  12.                          soma2(te) = Mid$(nt$(re), cor1(ag), 2)
  13.                     Next ag
  14.                     Color 7
  15.                End If
  16.  
  17.                If g = 4 Then
  18.                     Color 10
  19.                     Locate h, x + 3: Print "=>";: Print " QUADRA"
  20.                     For ag = 1 To 4
  21.                          qu = qu + 1
  22.                          Locate h, 51 + cor1(ag): Print Mid$(nt$(re), cor1(ag), 2)
  23.                          soma1$(qu) = Mid$(nt$(re), cor1(ag), 2)
  24.                     Next ag
  25.                     Color 7
  26.                End If
  27.  
  28.                If g = 5 Then
  29.                     Color 3
  30.                     Locate h, x + 3: Print "=>";: Print " QUINA"
  31.                     For ag = 1 To 5
  32.                          Locate h, 51 + cor1(ag): Print Mid$(nt$(re), cor1(ag), 2)
  33.                     Next ag
  34.                     Color 7
  35.                End If
  36.  
  37.                If g = 6 Then
  38.                     Color 14
  39.                     Locate h, x + 3:: Print "=>";: Print " SENA "
  40.                     For ag = 1 To 6
  41.                          Locate h, 51 + cor1(ag): Print Mid$(nt$(re), cor1(ag), 2)
  42.                     Next ag
  43.                     Color 7
  44.                End If
  45.                g = 0
  46.           Next


3
Programs / Re: Line with repeated numbers
« on: August 04, 2021, 05:55:44 pm »
Bplus

Below is an image of the alert that I intended to insert, to make the code more elegant.

As there is no simple way to do this.

I'll leave it as it is.

I want you to know, that when you answer my weird questions.

You make me so happy.

Thank you from the heart.

Carlos

Code: QB64: [Select]
  1. [/_Title "Qbasic 64" ' Many lines, created with help friend Bplus
  2. Screen _NewImage(600, 600, 256)
  3. _Delay .25
  4.  
  5. 'Moldura...
  6. Line (0, 0)-(599, 599), 11, B 'Moldura inteira
  7. Line (1, 1)-(598, 598), 11, B
  8. Line (2, 2)-(597, 597), 11, B
  9. Line (3, 3)-(596, 596), 11, B
  10. Line (4, 4)-(595, 595), 11, B
  11.  
  12. Line (599, 43)-(2, 43), 11, B 'Linha Horizontal
  13. Line (599, 44)-(2, 44), 11, B
  14.  
  15. 'Mostra Data
  16. d$ = Mid$(Date$, 1, 3)
  17. c$ = Mid$(Date$, 4, 3)
  18. e$ = Mid$(Date$, 7, 4)
  19. f$ = c$ + d$ + e$
  20.  
  21. Color 11: Locate 2, 28: Print "* * * Mega Sena * * *"
  22. Locate 2, 4: Print f$
  23. '--------------------------------------------------------------------------------
  24. Dim nt(0 To 3000) As String
  25. Dim cadastro As Long
  26.  
  27.  
  28. If _FileExists("mega.txt") Then
  29.      Open "mega.txt" For Input As #1
  30.      cadastro = LOF(1) \ 19
  31.      For t = 1 To cadastro
  32.           Line Input #1, nt$(t)
  33.      Next
  34.      Close
  35.      Open "mega.txt" For Append As #1
  36.      Open "mega.txt" For Output As #1
  37.      done = 1
  38.  
  39.      Color 30
  40.      Locate 12, 3: Print "Concurso =>"; cadastro; "= "; nt$(cadastro)
  41.      Locate 30, 3: Print "Pressione [ESC] para sair."
  42.      Locate 4, 3: Print "N" + Chr$(163); "meros de concursos =>"; cadastro
  43.  
  44.      Locate 6, 14: Print "_____________"
  45.      Locate 6, 3: Print "Dezenas => ";
  46.      a$ = ExtendedInput$ 'code Mr. SMcNeill
  47.  
  48.      For r = 6 To 30
  49.           Locate r, 2: Print Spc(72)
  50.      Next
  51.  
  52.      For i = 1 To 12 Step 2
  53.           x$ = x$ + Mid$(a$, i, 2) + " "
  54.      Next
  55.  
  56.      x$ = _Trim$(x$)
  57.  
  58.      For i = 1 To cadastro
  59.           If x$ = nt$(i) Then
  60.                done = 0
  61.                Color 48
  62.                Locate 15, 25: Print "Contest:"; i; "exists!!!! "
  63.                Locate 17, 29: Print ; nt$(i);
  64.                Locate 18, 29: Print "================="
  65.                Color 30
  66.                Beep
  67.                Exit For
  68.           End If
  69.      Next
  70.  
  71.      Locate 8, 3: Print "Dezenas => "; x$
  72.      Locate 10, 3: Print "N£meros de digitos ="; Len(a$)
  73.  
  74.  
  75.      If Len(a$) = 12 And done = 1 Then
  76.           Print #1, x$
  77.           Color 48
  78.           Locate 15, 24: Print "Dezenas salvas com sucesso!!!"
  79.           Locate 16, 24: Print "============================="
  80.           Locate 18, 30: Print x$
  81.           Locate 19, 30: Print "================="
  82.           cadastro = cadastro + 1
  83.           nt$(cadastro) = x$
  84.           nt$ = x$
  85.           Beep
  86.      ElseIf Len(a$) > 12 Then
  87.           Color 48
  88.           Locate 20, 23: Print "Number of digits greater than 12 =>"; Len(a$)
  89.           Locate 22, 30: Print ; a$
  90.           Locate 23, 31: Print "============="
  91.           Color 30
  92.           Beep
  93.      End If
  94.  
  95.      x$ = ""
  96.      Scrn$ = InKey$
  97. Loop Until Scrn$ = Chr$(27)
  98.  
  99. Play "o3l32ceff+g"
  100. Play "mfo4l64ceg>c"
  101.  
  102. OE20 = _LoadFont("century.ttf", 82)
  103. _Font OE20
  104. Color 11 ' &H200000FF
  105. Locate 4, 90: Print " QBasic 64 "
  106. Locate 5, 90: Print " -------------- "
  107.  
  108. '--------------------------------------------------------------------------------
  109.  
  110. Function ExtendedInput$ 'code Mr. SMcNeill
  111.      PCopy 0, 1
  112.      A = _AutoDisplay: X = Pos(0): Y = CsrLin
  113.      CP = 0: OldCP = 0 'Cursor Position
  114.      _KeyClear
  115.      Do
  116.           PCopy 1, 0
  117.           If _KeyDown(100307) Or _KeyDown(100308) Then AltDown = -1 Else AltDown = 0
  118.           k = _KeyHit
  119.           If AltDown Then
  120.                Select Case k 'ignore all keypresses except ALT-number presses
  121.                     Case 48 TO 57: AltWasDown = -1: alt$ = alt$ + Chr$(k)
  122.                End Select
  123.           Else
  124.                Select Case k 'without alt, add any keypresses to our input
  125.                     Case 8
  126.                          oldin$ = in$
  127.                          If CP > 0 Then OldCP = CP: CP = CP - 1
  128.                          in$ = Left$(in$, CP) + Mid$(in$, CP + 2) 'backspace to erase input
  129.                     Case 9
  130.                          oldin$ = in$
  131.                          in$ = Left$(in$, CP) + Space$(4) + Mid$(in$, CP + 1) 'four spaces for any TAB entered
  132.                          OldCP = CP
  133.                          CP = CP + 4
  134.                     Case 32 TO 128
  135.                          If _KeyDown(100305) Or _KeyDown(100306) Then
  136.                               If k = 118 Or k = 86 Then
  137.                                    oldin$ = in$
  138.                                    in$ = Left$(in$, CP) + _Clipboard$ + Mid$(in$, CP + 1) 'ctrl-v paste
  139.                                    'CTRL-V leaves cursor in position before the paste, without moving it after.
  140.                                    'Feel free to modify that behavior here, if you want it to move to after the paste.
  141.                                    CP = CP + Len(_Clipboard$)
  142.                               End If
  143.                               If k = 122 Or k = 90 Then Swap in$, oldin$: Swap OldCP, CP 'ctrl-z undo
  144.                          Else
  145.                               oldin$ = in$
  146.                               in$ = Left$(in$, CP) + Chr$(k) + Mid$(in$, CP + 1) 'add input to our string
  147.                               OldCP = CP
  148.                               CP = CP + 1
  149.                          End If
  150.                     Case 18176 'Home
  151.                          CP = 0
  152.                     Case 20224 'End
  153.                          CP = Len(in$)
  154.                     Case 21248 'Delete
  155.                          oldin$ = in$
  156.                          in$ = Left$(in$, CP) + Mid$(in$, CP + 2)
  157.                     Case 19200 'Left
  158.                          CP = CP - 1
  159.                          If CP < 0 Then CP = 0
  160.                     Case 19712 'Right
  161.                          CP = CP + 1
  162.                          If CP > Len(in$) Then CP = Len(in$)
  163.                End Select
  164.           End If
  165.           alt$ = Right$(alt$, 3)
  166.           If AltWasDown = -1 And AltDown = 0 Then
  167.                v = Val(alt$)
  168.                If v >= 0 And v <= 255 Then in$ = in$ + Chr$(v)
  169.                alt$ = "": AltWasDown = 0
  170.           End If
  171.           blink = (blink + 1) Mod 30
  172.           Locate Y, X
  173.           Print Left$(in$, CP);
  174.           If blink \ 15 Then Print " "; Else Print "_";
  175.           Print Mid$(in$, CP + 1)
  176.  
  177.           _Display
  178.           _Limit 30
  179.      Loop Until k = 13
  180.  
  181.      PCopy 1, 0
  182.      Locate Y, X: Print in$
  183.      ExtendedInput$ = in$
  184.      If A Then _AutoDisplay
  185. ]

4
Programs / Re: Line with repeated numbers
« on: August 03, 2021, 09:41:44 pm »
Okay, Bplus

I thought that with the settings I use, I could do the same

I wanted for a kind of alert.

Thanks again.

Carlos

5
Programs / Re: Line with repeated numbers
« on: August 03, 2021, 06:12:55 pm »
 line 8 from 24 to 25.
FOR i = 1 TO 24

FOR i = 1 TO 24
    t = 1
    FOR j = i + 1 TO 25

For

FOR i = 1 TO 25
    t = 0
    FOR j = i + 1 TO 25

The t=0 I left as the previous one
t=1


6
Programs / Re: Line with repeated numbers
« on: August 03, 2021, 05:53:51 pm »
Before thanking,

I would like to ask if there is color in Qbasic 64 as in the example below.

Code: QB64: [Select]
  1. [Color 30
  2. Print "qbasic"
  3. Print "Bplus"]

The names keep flashing.

I searched the wiki and I didn't find anything

I always use:

_Title "Qbasic 64"
Screen _NewImage(700, 740, 256)
_Delay .25
_ScreenMove 20, 30

The _Newlmage screen seems to disable this old qbsic effect.

As always, thank you in advance.

Carlos

7
Programs / Re: Line with repeated numbers
« on: August 03, 2021, 05:31:23 pm »
Good night, Bplus.

That's what I wasn't seeing.

A small change on line 8 from 24 to 25.
FOR i = 1 TO 24

FOR i = 1 TO 24
    t = 1
    FOR j = i + 1 TO 25

For

FOR i = 1 TO 25
    t = 0
    FOR j = i + 1 TO 25

That's what you did and I didn't see it.

Bplus, around here, things are very complicated.

So I created this code with your help, I mean, almost every line of code was with your help and willingness to respond.

I'm trying to find a pattern in the numbers.

More already realized that there is not.

I was trying to help luck when I sometimes make a bet.

8
Programs / Re: Line with repeated numbers
« on: July 12, 2021, 09:32:39 am »
Quote
Sorry not interested in immersing into this again, since last time I built an Interpreter, fixed String Math and made nice Pool game. My head and heart is a million miles away from this.

All right, Bplus
I didn't know you were too busy.
A hug.
Carlos.

9
Programs / Re: Line with repeated numbers
« on: July 11, 2021, 08:16:52 pm »
Good night, Bplus

Before I come to ask for your help, I try very hard to resolve it on my own.

This code of yours, to separate lines with repeated numbers, served me a lot at the time you created it.
Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(800, 440, 32)
  2. REDIM fileLines(1 TO 25) AS STRING
  3. OPEN "numbers.txt" FOR INPUT AS #1 ' get data from file
  4. FOR i = 1 TO 25
  5.     LINE INPUT #1, fileLines(i)
  6. FOR i = 1 TO 24
  7.     t = 1
  8.     FOR j = i + 1 TO 25
  9.         IF _TRIM$(fileLines(i)) = _TRIM$(fileLines(j)) AND _TRIM$(fileLines(i)) <> "" THEN
  10.             t = t + 1
  11.             fileLines(j) = ""
  12.         END IF
  13.     NEXT
  14.     IF t > 1 THEN PRINT t; " "; fileLines(i)
  15.  
  16.  

used it to count repeated numbers from the attached code.

Bplus, could you modify or have another idea to count numbers that come out only once?

When I insert it in the attached code, it doesn't count the number 37 as the attached image.

Code: QB64: [Select]
  1.           For i = 1 To qu - 1 'Line with repeated numbers Bplus
  2.                t = 1
  3.                For j = i + 1 To qu
  4.                     If _Trim$(soma1(i)) = _Trim$(soma1(j)) And _Trim$(soma1(i)) <> "" Then
  5.                          t = t + 1
  6.                          soma1(j) = ""
  7.                     End If
  8.                Next
  9.  
  10.                If t > 1 Then
  11.                     Color 30
  12.                     Locate i + 10, 5
  13.                     Print "Dezena = ";
  14.                     Color 10
  15.                     Locate i + 10, 8
  16.                     Print " "; soma1(i);
  17.                     Color 30
  18.                     Locate i + 10, 12
  19.                     Print "="; t
  20.                End If
  21.           Next
  22.      Else
Put this string when running the code
083033374548

Carlos

10
Programs / Re: Mr. McNeill's extended entrance
« on: February 07, 2021, 05:06:34 pm »
Quote
'IF h > 41 THEN
COLOR 13: LOCATE 44, 34: PRINT "Pressione Enter para continuar..."

DO
    IF INKEY$ = "" THEN EXIT DO
LOOP

DO
    _LIMIT 30
LOOP UNTIL INKEY$ = CHR$(13)

NOVARSEG so I will have to press the enter key twice. Thanks for another suggestion.

Quote
Glad you have it worked out Carlos, beats me what you were up to!  :)

I thought it would solve Bplus, not this time.

What I did was move the _KeyClear that you showed in your last example.

Dentro:

Code: QB64: [Select]
  1.     COLOR 30
  2.     'PRINT ExtendedInput$
  3.     LOCATE 6, 14: PRINT "_______________________________"
  4.     LOCATE 6, 3: PRINT "Dezenas => ";
  5.     a$ = ExtendedInput$
  6.  
  7.     ' _KEYCLEAR
  8.  
  9.     FOR i = 1 TO 30 STEP 2
  10.         x$ = x$ + MID$(a$, i, 2) + " "
  11.     NEXT

For:

Code: QB64: [Select]
  1.         FOR rs = 1 TO pesquisa
  2.             IF h > 41 THEN
  3.                 _KEYCLEAR
  4.                 COLOR 13: LOCATE 44, 34: PRINT "Pressione Enter para continuar..."
  5.                 DO
  6.                     _LIMIT 30
  7.                 LOOP UNTIL INKEY$ = CHR$(13)

So far everything is fine.

Thank you all, for all the suggestions and encouragement.

I keep learning here, in this forum.

Carlos


11
Programs / Re: Mr. McNeill's extended entrance
« on: February 06, 2021, 07:01:03 pm »
Mr. SMcNeill and Bplux

Since the beginning of this post, I was confused.

Asking me why chr $ (22) interferes in:

  OF
                _LIMIT 30
             LOOP UNTIL INKEY $ = CHR $ (13)

Today I found out that chr $ (22) is not the real problem with the loop going two laps before stopping.

The keyboard buffer also holds CHR $ (13).

This is what causes the loop to start, without me pressing the Enter key.

See image

Wouldn't it be better to clean only the CR $ (13)?

Quote
It's rigged to do 100 repeated things before even exiting and checking the outside loop,

_Keydown works just fine AFTER 100 silly loops! (press enter 100 x's now we finally check if escape pressed!)

Try this for an inner loop of 100 times:
Bplus, perform very well by holding the ESC key while pressing ENTER

A única solução que encontrei para limpar o buffer.

Repita o:
DO
                  _LIMIT 30
               LOOP ATÉ INKEY $ = CHR $ (13)

para limpar o CR $ (13).

Carlos

12
Programs / Re: Mr. McNeill's extended entrance
« on: February 05, 2021, 08:29:23 pm »
Okay, I'll try again tomorrow.

Thank you for answering Mr. SMcNeill. Thank you Bplus.

Tomorrow I'll be back again :)

Carlos

13
Programs / Re: Mr. McNeill's extended entrance
« on: February 05, 2021, 08:21:57 pm »
Quote
ou Carlos poderia :)

you are very funny, Bplus

the Loop until _Keydown (27) didn't work.

The code I'm using with your extended entry code

14
Programs / Re: Mr. McNeill's extended entrance
« on: February 05, 2021, 07:56:53 pm »
Quote
Carlos man! you are pointing exactly where 22 is coming from!

That is what you press to copy / paste the clipboard!

That gets stuck in INKEY$ buffer and use _KEYCLEAR to remove it.

I added _KEYCLEAR Bplus,

however, that left me without CH $ (27) to leave.

Sc $ = INKEY $
LOOP UNTIL Sc $ = CHR $ (27) "press to exit"

15
Programs / Re: Mr. McNeill's extended entrance
« on: February 05, 2021, 07:43:08 pm »
Quote
First, and most obvious question to ask, is it a CHR$ that you’re copying when you copy the contents into the clipboard?  Check length of  _clipboard$ And only take the LEFT$(_CLIPBOARD$,desired_number_of_digits) and see if that gets rid of any stray, extra input.

I understand now, Mr. SMcNeill.

I'm copying CHR $ from "Ctrl + V"

After searching the wiki, I found out what you meant.

According to the attached table

_KEYCLEAR solved CHR $.

however, it left me without CH $ (27) to leave.

Sc $ = INKEY $
LOOP UNTIL Sc $ = CHR $ (27) "press to exit"

As I understand it, the "LEFT $ (_ CLIPBOARD $, needed_number_of_digits)".

It would be here. "in $ = LEFT $ (in $, CP) + LEFT $ (_ CLIPBOARD $, 30) + MID $ (in $, CP + 1)"?

Mr. SMcNeill. how to eliminate CHR $ (22)?

I would very much like you to respond.

I believe I am at the limit of 3 days

Carlos

Pages: [1] 2 3 ... 7