Author Topic: Mr. McNeill's extended entrance  (Read 11428 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Mr. McNeill's extended entrance
« Reply #30 on: February 04, 2021, 08:10:07 pm »
Here is where the 22 is coming from but I haven't a clue what you are trying to do with this new code.

Code: QB64: [Select]
  1. _TITLE "Qbasic 64"
  2. SCREEN _NEWIMAGE(600, 600, 256)
  3. _DELAY .25
  4.  
  5.  
  6. 'PRINT ExtendedInput$
  7.  
  8. LOCATE 2, 14: PRINT "_______________________________"
  9. LOCATE 2, 3: PRINT "Dozens => ";
  10. a$ = ExtendedInput$
  11.  
  12. h = 4
  13. j = 2
  14. 'K$ = INKEY$   '<<<<<<<<<<<<<<<<<<<<<<<<<< what is this for?
  15. K$ = "Ola Mundo"  ' >>>> see how it effects your code?
  16.     FOR e = 1 TO 100
  17.         h = h + 1
  18.         IF h > 10 THEN
  19.             COLOR 30: LOCATE 30, 3: PRINT "Press Enter to continue ..."
  20.             DO
  21.                 _LIMIT 30
  22.             LOOP UNTIL INKEY$ = CHR$(13)
  23.             h = 5: j = 25
  24.         END IF
  25.  
  26.         FOR i = 1 TO 30 STEP 2
  27.             x$ = x$ + MID$(a$, i, 2) + " "
  28.         NEXT
  29.  
  30.         x$ = _TRIM$(x$)
  31.  
  32.         _LIMIT 60
  33.  
  34.         LOCATE h, j: PRINT "test"; e; " k$ = "; k$; ASC(k$)
  35.     NEXT
  36.     Scrn$ = INKEY$
  37. LOOP UNTIL Scrn$ = CHR$(27)
  38.  
  39.  
  40. FUNCTION ExtendedInput$
  41.     PCOPY 0, 1
  42.     A = _AUTODISPLAY: X = POS(0): Y = CSRLIN
  43.     CP = 0: OldCP = 0 'Cursor Position
  44.     _KEYCLEAR
  45.     DO
  46.         PCOPY 1, 0
  47.         IF _KEYDOWN(100307) OR _KEYDOWN(100308) THEN AltDown = -1 ELSE AltDown = 0
  48.         k = _KEYHIT
  49.         IF AltDown THEN
  50.             SELECT CASE k 'ignore all keypresses except ALT-number presses
  51.                 CASE 48 TO 57: AltWasDown = -1: alt$ = alt$ + CHR$(k)
  52.             END SELECT
  53.         ELSE
  54.             SELECT CASE k 'without alt, add any keypresses to our input
  55.                 CASE 8
  56.                     oldin$ = in$
  57.                     IF CP > 0 THEN OldCP = CP: CP = CP - 1
  58.                     in$ = LEFT$(in$, CP) + MID$(in$, CP + 2) 'backspace to erase input
  59.                 CASE 9
  60.                     oldin$ = in$
  61.                     in$ = LEFT$(in$, CP) + SPACE$(4) + MID$(in$, CP + 1) 'four spaces for any TAB entered
  62.                     OldCP = CP
  63.                     CP = CP + 4
  64.                 CASE 32 TO 128
  65.                     IF _KEYDOWN(100305) OR _KEYDOWN(100306) THEN
  66.                         IF k = 118 OR k = 86 THEN
  67.                             oldin$ = in$
  68.                             in$ = LEFT$(in$, CP) + _CLIPBOARD$ + MID$(in$, CP + 1) 'ctrl-v paste
  69.                             'CTRL-V leaves cursor in position before the paste, without moving it after.
  70.                             'Feel free to modify that behavior here, if you want it to move to after the paste.
  71.                             CP = CP + LEN(_CLIPBOARD$)
  72.                         END IF
  73.                         IF k = 122 OR k = 90 THEN SWAP in$, oldin$: SWAP OldCP, CP 'ctrl-z undo
  74.                     ELSE
  75.                         oldin$ = in$
  76.                         in$ = LEFT$(in$, CP) + CHR$(k) + MID$(in$, CP + 1) 'add input to our string
  77.                         OldCP = CP
  78.                         CP = CP + 1
  79.                     END IF
  80.                 CASE 18176 'Home
  81.                     CP = 0
  82.                 CASE 20224 'End
  83.                     CP = LEN(in$)
  84.                 CASE 21248 'Delete
  85.                     oldin$ = in$
  86.                     in$ = LEFT$(in$, CP) + MID$(in$, CP + 2)
  87.                 CASE 19200 'Left
  88.                     CP = CP - 1
  89.                     IF CP < 0 THEN CP = 0
  90.                 CASE 19712 'Right
  91.                     CP = CP + 1
  92.                     IF CP > LEN(in$) THEN CP = LEN(in$)
  93.             END SELECT
  94.         END IF
  95.         alt$ = RIGHT$(alt$, 3)
  96.         IF AltWasDown = -1 AND AltDown = 0 THEN
  97.             v = VAL(alt$)
  98.             IF v >= 0 AND v <= 255 THEN in$ = in$ + CHR$(v)
  99.             alt$ = "": AltWasDown = 0
  100.         END IF
  101.         blink = (blink + 1) MOD 30
  102.         LOCATE Y, X
  103.         PRINT LEFT$(in$, CP);
  104.         IF blink \ 15 THEN PRINT " "; ELSE PRINT "_";
  105.         PRINT MID$(in$, CP + 1)
  106.  
  107.         _DISPLAY
  108.         _LIMIT 30
  109.     LOOP UNTIL k = 13
  110.  
  111.     PCOPY 1, 0
  112.     LOCATE Y, X: PRINT in$
  113.     ExtendedInput$ = in$
  114.  


Why aren't you printing x$ or something that makes more sense? Why the repeating K$?

What's this suppose to look like when correct?

« Last Edit: February 04, 2021, 08:28:10 pm by bplus »

Offline carloscordeiro

  • Forum Regular
  • Posts: 102
    • View Profile
Re: Mr. McNeill's extended entrance
« Reply #31 on: February 04, 2021, 09:00:27 pm »
Quote
Hi Carlos,

I'm still here but this looks to me a note addressed to Steve, so I let it alone.
 .

Yes, it was addressed to Steve.
But I think I bothered him.
I didn't get an answer even though it was within the 3 days he gave.

I put the K $ to print the 22.

K $ is not part of the code

Bplus, see the complete code so as not to confuse you.

I will delete the k $. He will still skip line 78. IF h> 41 THEN stop.

The loop takes two turns before stopping.

Dezenas para testar
010204080910121314151617182023

Code: QB64: [Select]
  1. _TITLE "Qbasic 64"
  2. SCREEN _NEWIMAGE(700, 740, 256)
  3. _DELAY .25
  4.  
  5. 'Moldura...
  6. LINE (0, 0)-(699, 739), 11, B 'Moldura inteira
  7. LINE (1, 1)-(698, 738), 11, B
  8. LINE (2, 2)-(697, 737), 11, B
  9. LINE (3, 3)-(696, 736), 11, B
  10. LINE (4, 4)-(695, 735), 11, B
  11.  
  12. LINE (699, 43)-(2, 43), 11, B 'Linha Horizontal
  13. LINE (699, 44)-(2, 44), 11, B
  14.  
  15. LINE (536, 737)-(536, 44), 11, B 'Linha Vertical
  16. LINE (535, 737)-(535, 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, 35: PRINT "* * * LOTOFACIL * * *"
  25. LOCATE 2, 4: PRINT f$: COLOR 7
  26.  
  27. '------------------------------------------------------------------------
  28. DIM cor1(80) AS _INTEGER64
  29. DIM nt(1 TO 3000) AS STRING
  30. DIM pesquisa AS LONG
  31.  
  32.  
  33. OPEN "loto.txt" FOR INPUT AS #1
  34. pesquisa = LOF(1) \ 46
  35. FOR t = 1 TO pesquisa
  36.     LINE INPUT #1, nt$(t)
  37.  
  38. COLOR 15: LOCATE 4, 3: PRINT "N" + CHR$(163); "meros de concursos =>"; pesquisa
  39.  
  40.     COLOR 30
  41.     'PRINT ExtendedInput$
  42.     LOCATE 6, 14: PRINT "_______________________________"
  43.     LOCATE 6, 3: PRINT "Dezenas => ";
  44.     a$ = ExtendedInput$
  45.  
  46.     'K$ = INKEY$ ' ASCII code number
  47.  
  48.     FOR i = 1 TO 30 STEP 2
  49.         x$ = x$ + MID$(a$, i, 2) + " "
  50.     NEXT
  51.     Pes$ = _TRIM$(x$)
  52.  
  53.     IF LEN(Pes$) = 44 THEN
  54.         LOCATE 8, 3: PRINT "Dezenas => "; Pes$; " ="; LEN(Pes$)
  55.         g = 0
  56.         h = 9
  57.         onze = 0
  58.         doze = 0
  59.         trez = 0
  60.         quat = 0
  61.  
  62.         'COLOR 13: LOCATE 44, 3: PRINT "Digite [ S ] para SAIR..."
  63.         ' COLOR 15
  64.         'LOCATE 44, 34: PRINT "                                 "
  65.         'LOCATE 6, 14: PRINT "____________________________________________"
  66.         ' LOCATE 6, 3: INPUT "Dezenas => ", pes$
  67.         'COLOR 13: LOCATE 44, 3: PRINT "                         "
  68.  
  69.         '---------------------------------------------------------------------------
  70.  
  71.         FOR rs = 1 TO pesquisa
  72.             IF h > 41 THEN
  73.                 COLOR 13: LOCATE 44, 34: PRINT "Pressione Enter para continuar..."
  74.                 DO
  75.                     _LIMIT 30
  76.                 LOOP UNTIL INKEY$ = CHR$(13)
  77.                 FOR S = 9 TO 43
  78.                     LOCATE S, 2: PRINT "                                                                 "
  79.                     LOCATE S, 70: PRINT "                "
  80.                 NEXT S
  81.                 h = 9
  82.             END IF
  83.             h = h + 1
  84.             x = 3
  85.             COLOR 15: LOCATE h, x: PRINT RIGHT$("0000" + LTRIM$(STR$(rs)), 4); " => "
  86.  
  87.             FOR i = 1 TO 44 STEP 3
  88.                 x = x + 3
  89.                 tt$ = MID$(nt$(rs), i, 2)
  90.                 FOR r = 1 TO LEN(Pes$) STEP 3
  91.                     O$ = MID$(Pes$, r, 2)
  92.                     IF tt$ = O$ THEN
  93.                         g = g + 1
  94.                         cor1(g) = i
  95.                         EXIT FOR
  96.                     ELSE
  97.                         COLOR 7: LOCATE h, x + 5: PRINT tt$
  98.                     END IF
  99.                 NEXT r
  100.             NEXT i
  101.  
  102.             IF g <= 10 THEN
  103.                 LOCATE h, 2: PRINT "                                                        "
  104.                 h = h - 1
  105.                 g = 0
  106.             END IF
  107.  
  108.             IF g = 11 THEN
  109.                 onze = onze + 1
  110.                 COLOR 48
  111.                 LOCATE h, x + 8: PRINT "=>";: PRINT " Onze"
  112.                 FOR ag = 1 TO 11
  113.                     LOCATE h, 10 + cor1(ag): PRINT MID$(nt$(rs), cor1(ag), 2)
  114.                 NEXT ag
  115.                 COLOR 7
  116.             END IF
  117.  
  118.             IF g = 12 THEN
  119.                 doze = doze + 1
  120.                 COLOR 52
  121.                 LOCATE h, x + 8: PRINT "=>";: PRINT " Doze"
  122.                 FOR ag = 1 TO 12
  123.                     LOCATE h, 10 + cor1(ag): PRINT MID$(nt$(rs), cor1(ag), 2)
  124.                 NEXT ag
  125.                 COLOR 7
  126.             END IF
  127.  
  128.             IF g = 13 THEN
  129.                 trez = trez + 1
  130.                 COLOR 36
  131.                 LOCATE h, x + 8: PRINT "=>";: PRINT " Treze"
  132.                 FOR ag = 1 TO 13
  133.                     LOCATE h, 10 + cor1(ag): PRINT MID$(nt$(rs), cor1(ag), 2)
  134.                 NEXT ag
  135.                 COLOR 7
  136.             END IF
  137.  
  138.             IF g = 14 THEN
  139.                 quat = quat + 1
  140.                 COLOR 40
  141.                 LOCATE h, x + 8: PRINT "=>";: PRINT " Quatorze"
  142.                 FOR ag = 1 TO 14
  143.                     LOCATE h, 10 + cor1(ag): PRINT MID$(nt$(rs), cor1(ag), 2)
  144.                 NEXT ag
  145.                 COLOR 7
  146.             END IF
  147.  
  148.             IF g = 15 THEN
  149.                 COLOR 68
  150.                 LOCATE h, x + 8: PRINT "=>";: PRINT " Quinze"
  151.                 FOR ag = 1 TO 15
  152.                     LOCATE h, 10 + cor1(ag): PRINT MID$(nt$(rs), cor1(ag), 2)
  153.                 NEXT ag
  154.                 COLOR 7
  155.             END IF
  156.  
  157.             g = 0
  158.  
  159.  
  160.             'LOCATE 18, 69: PRINT "k$ ASCII code "; K$ 'ASCII code
  161.             ' LOCATE 20, 69: PRINT "k$ ASCII code "; ASC(K$) 'Shows ASCII code number
  162.  
  163.  
  164.             COLOR 48
  165.             LOCATE 8, 70: PRINT "N11:"; RIGHT$("000" + LTRIM$(STR$(onze)), 3); " - Vezes"
  166.             COLOR 52
  167.             LOCATE 10, 70: PRINT "N12:"; RIGHT$("000" + LTRIM$(STR$(doze)), 3); " - Vezes"
  168.             COLOR 36
  169.             LOCATE 12, 70: PRINT "N13:"; RIGHT$("000" + LTRIM$(STR$(trez)), 3); " - Vezes"
  170.             COLOR 40
  171.             LOCATE 14, 70: PRINT "N13:"; RIGHT$("000" + LTRIM$(STR$(quat)), 3); " - Vezes"
  172.         NEXT
  173.     ELSE
  174.         BEEP
  175.     END IF
  176.     x$ = ""
  177.     Scrn$ = INKEY$
  178. LOOP UNTIL Scrn$ = CHR$(27)
  179.  
  180.  
  181. '--------------------------------------------------------------------------------
  182.  
  183. FUNCTION ExtendedInput$
  184.     PCOPY 0, 1
  185.     A = _AUTODISPLAY: X = POS(0): Y = CSRLIN
  186.     CP = 0: OldCP = 0 'Cursor Position
  187.     _KEYCLEAR
  188.     DO
  189.         PCOPY 1, 0
  190.         IF _KEYDOWN(100307) OR _KEYDOWN(100308) THEN AltDown = -1 ELSE AltDown = 0
  191.         k = _KEYHIT
  192.         IF AltDown THEN
  193.             SELECT CASE k 'ignore all keypresses except ALT-number presses
  194.                 CASE 48 TO 57: AltWasDown = -1: alt$ = alt$ + CHR$(k)
  195.             END SELECT
  196.         ELSE
  197.             SELECT CASE k 'without alt, add any keypresses to our input
  198.                 CASE 8
  199.                     oldin$ = in$
  200.                     IF CP > 0 THEN OldCP = CP: CP = CP - 1
  201.                     in$ = LEFT$(in$, CP) + MID$(in$, CP + 2) 'backspace to erase input
  202.                 CASE 9
  203.                     oldin$ = in$
  204.                     in$ = LEFT$(in$, CP) + SPACE$(4) + MID$(in$, CP + 1) 'four spaces for any TAB entered
  205.                     OldCP = CP
  206.                     CP = CP + 4
  207.                 CASE 32 TO 128
  208.                     IF _KEYDOWN(100305) OR _KEYDOWN(100306) THEN
  209.                         IF k = 118 OR k = 86 THEN
  210.                             oldin$ = in$
  211.                             in$ = LEFT$(in$, CP) + _CLIPBOARD$ + MID$(in$, CP + 1) 'ctrl-v paste
  212.                             'CTRL-V leaves cursor in position before the paste, without moving it after.
  213.                             'Feel free to modify that behavior here, if you want it to move to after the paste.
  214.                             CP = CP + LEN(_CLIPBOARD$)
  215.                         END IF
  216.                         IF k = 122 OR k = 90 THEN SWAP in$, oldin$: SWAP OldCP, CP 'ctrl-z undo
  217.                     ELSE
  218.                         oldin$ = in$
  219.                         in$ = LEFT$(in$, CP) + CHR$(k) + MID$(in$, CP + 1) 'add input to our string
  220.                         OldCP = CP
  221.                         CP = CP + 1
  222.                     END IF
  223.                 CASE 18176 'Home
  224.                     CP = 0
  225.                 CASE 20224 'End
  226.                     CP = LEN(in$)
  227.                 CASE 21248 'Delete
  228.                     oldin$ = in$
  229.                     in$ = LEFT$(in$, CP) + MID$(in$, CP + 2)
  230.                 CASE 19200 'Left
  231.                     CP = CP - 1
  232.                     IF CP < 0 THEN CP = 0
  233.                 CASE 19712 'Right
  234.                     CP = CP + 1
  235.                     IF CP > LEN(in$) THEN CP = LEN(in$)
  236.             END SELECT
  237.         END IF
  238.         alt$ = RIGHT$(alt$, 3)
  239.         IF AltWasDown = -1 AND AltDown = 0 THEN
  240.             v = VAL(alt$)
  241.             IF v >= 0 AND v <= 255 THEN in$ = in$ + CHR$(v)
  242.             alt$ = "": AltWasDown = 0
  243.         END IF
  244.         blink = (blink + 1) MOD 30
  245.         LOCATE Y, X
  246.         PRINT LEFT$(in$, CP);
  247.         IF blink \ 15 THEN PRINT " "; ELSE PRINT "_";
  248.         PRINT MID$(in$, CP + 1)
  249.  
  250.         _DISPLAY
  251.         _LIMIT 30
  252.     LOOP UNTIL k = 13
  253.  
  254.     PCOPY 1, 0
  255.     LOCATE Y, X: PRINT in$
  256.     ExtendedInput$ = in$
« Last Edit: February 04, 2021, 09:18:58 pm by carloscordeiro »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Mr. McNeill's extended entrance
« Reply #32 on: February 04, 2021, 09:35:14 pm »
Try h > 40

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Mr. McNeill's extended entrance
« Reply #33 on: February 04, 2021, 10:19:35 pm »
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.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline carloscordeiro

  • Forum Regular
  • Posts: 102
    • View Profile
Re: Mr. McNeill's extended entrance
« Reply #34 on: February 04, 2021, 11:08:38 pm »
Quote
Verifique o comprimento do _clipboard $ E apenas pegue o LEFT $ (_ CLIPBOARD $, needed_number_of_digits) e veja se isso se livra de qualquer entrada extra perdida.
Good evening, Mr. SMcNeill.

This is exactly what may be happening

This time I'm taking great care not to confuse you.

I didn't enter my code, just leave the space for the 30 digits.

I did what you asked for, but always keep the character 22 which I don't know where it is being copied from.

 typed the 30 tens, no extra lost characters.

Only when I copy.

I followed your suggestion with an image.

010203050708091112141516212325

Thank you for responding.

Carlos

Code: QB64: [Select]
  1. _TITLE "Qbasic 64"
  2. SCREEN _NEWIMAGE(600, 600, 256)
  3. _DELAY .25
  4.  
  5. 'PRINT ExtendedInput$
  6.  
  7. LOCATE 2, 14: PRINT "_______________________________"
  8. LOCATE 2, 3: PRINT "Dozens => ";
  9. a$ = ExtendedInput$
  10.  
  11. K$ = INKEY$
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22. FUNCTION ExtendedInput$
  23.     PCOPY 0, 1
  24.     A = _AUTODISPLAY: X = POS(0): Y = CSRLIN
  25.     CP = 0: OldCP = 0 'Cursor Position
  26.     _KEYCLEAR
  27.     DO
  28.         PCOPY 1, 0
  29.         IF _KEYDOWN(100307) OR _KEYDOWN(100308) THEN AltDown = -1 ELSE AltDown = 0
  30.         k = _KEYHIT
  31.         IF AltDown THEN
  32.             SELECT CASE k 'ignore all keypresses except ALT-number presses
  33.                 CASE 48 TO 57: AltWasDown = -1: alt$ = alt$ + CHR$(k)
  34.             END SELECT
  35.         ELSE
  36.             SELECT CASE k 'without alt, add any keypresses to our input
  37.                 CASE 8
  38.                     oldin$ = in$
  39.                     IF CP > 0 THEN OldCP = CP: CP = CP - 1
  40.                     in$ = LEFT$(in$, CP) + MID$(in$, CP + 2) 'backspace to erase input
  41.                 CASE 9
  42.                     oldin$ = in$
  43.                     in$ = LEFT$(in$, CP) + SPACE$(4) + MID$(in$, CP + 1) 'four spaces for any TAB entered
  44.                     OldCP = CP
  45.                     CP = CP + 4
  46.                 CASE 32 TO 128
  47.                     IF _KEYDOWN(100305) OR _KEYDOWN(100306) THEN
  48.                         IF k = 118 OR k = 86 THEN
  49.                             oldin$ = in$
  50.                             in$ = LEFT$(in$, CP) + _CLIPBOARD$ + MID$(in$, CP + 1) 'ctrl-v paste
  51.                             'CTRL-V leaves cursor in position before the paste, without moving it after.
  52.                             'Feel free to modify that behavior here, if you want it to move to after the paste.
  53.                             CP = CP + LEN(_CLIPBOARD$)
  54.                         END IF
  55.                         IF k = 122 OR k = 90 THEN SWAP in$, oldin$: SWAP OldCP, CP 'ctrl-z undo
  56.                     ELSE
  57.                         oldin$ = in$
  58.                         in$ = LEFT$(in$, CP) + CHR$(k) + MID$(in$, CP + 1) 'add input to our string
  59.                         OldCP = CP
  60.                         CP = CP + 1
  61.                     END IF
  62.                 CASE 18176 'Home
  63.                     CP = 0
  64.                 CASE 20224 'End
  65.                     CP = LEN(in$)
  66.                 CASE 21248 'Delete
  67.                     oldin$ = in$
  68.                     in$ = LEFT$(in$, CP) + MID$(in$, CP + 2)
  69.                 CASE 19200 'Left
  70.                     CP = CP - 1
  71.                     IF CP < 0 THEN CP = 0
  72.                 CASE 19712 'Right
  73.                     CP = CP + 1
  74.                     IF CP > LEN(in$) THEN CP = LEN(in$)
  75.             END SELECT
  76.         END IF
  77.         alt$ = RIGHT$(alt$, 3)
  78.         IF AltWasDown = -1 AND AltDown = 0 THEN
  79.             v = VAL(alt$)
  80.             IF v >= 0 AND v <= 255 THEN in$ = in$ + CHR$(v)
  81.             alt$ = "": AltWasDown = 0
  82.         END IF
  83.         blink = (blink + 1) MOD 30
  84.         LOCATE Y, X
  85.         PRINT LEFT$(in$, CP);
  86.         IF blink \ 15 THEN PRINT " "; ELSE PRINT "_";
  87.         PRINT MID$(in$, CP + 1)
  88.  
  89.         _DISPLAY
  90.         _LIMIT 30
  91.     LOOP UNTIL k = 13
  92.  
  93.     PCOPY 1, 0
  94.     LOCATE Y, X: PRINT in$
  95.     ExtendedInput$ = in$
30 digitos.jpg
* 30 digitos.jpg (Filesize: 166.5 KB, Dimensions: 1009x853, Views: 168)
30 digitos_02.jpg
* 30 digitos_02.jpg (Filesize: 137.18 KB, Dimensions: 919x789, Views: 166)
« Last Edit: February 04, 2021, 11:58:25 pm by carloscordeiro »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Mr. McNeill's extended entrance
« Reply #35 on: February 04, 2021, 11:28:20 pm »
Well I know where 22 is coming from :) I showed.

Why line 14 and why all the printing of K$ ?  22 is coming from INKEY$ you can clear INKEY$ if you want with _KEYCLEAR but then ASC(K$) will error.
« Last Edit: February 05, 2021, 12:08:56 am by bplus »

Offline carloscordeiro

  • Forum Regular
  • Posts: 102
    • View Profile
Re: Mr. McNeill's extended entrance
« Reply #36 on: February 05, 2021, 05:17:58 pm »
Quote
Why line 14 and why all the printing of K$ ?  22 is coming from INKEY$ you can clear INKEY$ if you want with _KEYCLEAR but then ASC(K$) will error.

The K $ impression is sybolic.

just to show the reason for the Loop to go twice.

_KEYCLEAR solved the problem of the intrusive ASCII code 22.

I didn't want to give up on Mr. SMcNeill's wonderful code.

Thanks again Bplus.

Carlos

Code: QB64: [Select]
  1. _TITLE "Qbasic 64"
  2. SCREEN _NEWIMAGE(600, 600, 256)
  3. _DELAY .25
  4.  
  5.  
  6. 'PRINT ExtendedInput$
  7.  
  8. LOCATE 2, 14: PRINT "_______________________________"
  9. LOCATE 2, 3: PRINT "Dozens => ";
  10. a$ = ExtendedInput$
  11.  
  12. _KEYCLEAR '_KEYCLEAR solved the problem of the intrusive ASCII code 22.
  13.  
  14. h = 4
  15. j = 2
  16. K$ = INKEY$
  17.     FOR e = 1 TO 100
  18.         h = h + 1
  19.         IF h > 10 THEN
  20.             COLOR 30: LOCATE 30, 3: PRINT "Press Enter to continue ..."
  21.             DO
  22.                 _LIMIT 30
  23.             LOOP UNTIL INKEY$ = CHR$(13)
  24.             h = 5: j = j + 20
  25.         END IF
  26.         FOR i = 1 TO 30 STEP 2
  27.             x$ = x$ + MID$(a$, i, 2) + " "
  28.         NEXT
  29.         x$ = _TRIM$(x$)
  30.         _LIMIT 60
  31.         LOCATE h, j: PRINT e; "_KEYCLEAR" ' ASC(K$)
  32.     NEXT
  33.     Scrn$ = INKEY$
  34. LOOP UNTIL Scrn$ = CHR$(27)
  35.  
  36.  
  37. FUNCTION ExtendedInput$
  38.     PCOPY 0, 1
  39.     A = _AUTODISPLAY: X = POS(0): Y = CSRLIN
  40.     CP = 0: OldCP = 0 'Cursor Position
  41.     _KEYCLEAR
  42.     DO
  43.         PCOPY 1, 0
  44.         IF _KEYDOWN(100307) OR _KEYDOWN(100308) THEN AltDown = -1 ELSE AltDown = 0
  45.         k = _KEYHIT
  46.         IF AltDown THEN
  47.             SELECT CASE k 'ignore all keypresses except ALT-number presses
  48.                 CASE 48 TO 57: AltWasDown = -1: alt$ = alt$ + CHR$(k)
  49.             END SELECT
  50.         ELSE
  51.             SELECT CASE k 'without alt, add any keypresses to our input
  52.                 CASE 8
  53.                     oldin$ = in$
  54.                     IF CP > 0 THEN OldCP = CP: CP = CP - 1
  55.                     in$ = LEFT$(in$, CP) + MID$(in$, CP + 2) 'backspace to erase input
  56.                 CASE 9
  57.                     oldin$ = in$
  58.                     in$ = LEFT$(in$, CP) + SPACE$(4) + MID$(in$, CP + 1) 'four spaces for any TAB entered
  59.                     OldCP = CP
  60.                     CP = CP + 4
  61.                 CASE 32 TO 128
  62.                     IF _KEYDOWN(100305) OR _KEYDOWN(100306) THEN
  63.                         IF k = 118 OR k = 86 THEN
  64.                             oldin$ = in$
  65.                             in$ = LEFT$(in$, CP) + _CLIPBOARD$ + MID$(in$, CP + 1) 'ctrl-v paste
  66.                             'CTRL-V leaves cursor in position before the paste, without moving it after.
  67.                             'Feel free to modify that behavior here, if you want it to move to after the paste.
  68.                             CP = CP + LEN(_CLIPBOARD$)
  69.                         END IF
  70.                         IF k = 122 OR k = 90 THEN SWAP in$, oldin$: SWAP OldCP, CP 'ctrl-z undo
  71.                     ELSE
  72.                         oldin$ = in$
  73.                         in$ = LEFT$(in$, CP) + CHR$(k) + MID$(in$, CP + 1) 'add input to our string
  74.                         OldCP = CP
  75.                         CP = CP + 1
  76.                     END IF
  77.                 CASE 18176 'Home
  78.                     CP = 0
  79.                 CASE 20224 'End
  80.                     CP = LEN(in$)
  81.                 CASE 21248 'Delete
  82.                     oldin$ = in$
  83.                     in$ = LEFT$(in$, CP) + MID$(in$, CP + 2)
  84.                 CASE 19200 'Left
  85.                     CP = CP - 1
  86.                     IF CP < 0 THEN CP = 0
  87.                 CASE 19712 'Right
  88.                     CP = CP + 1
  89.                     IF CP > LEN(in$) THEN CP = LEN(in$)
  90.             END SELECT
  91.         END IF
  92.         alt$ = RIGHT$(alt$, 3)
  93.         IF AltWasDown = -1 AND AltDown = 0 THEN
  94.             v = VAL(alt$)
  95.             IF v >= 0 AND v <= 255 THEN in$ = in$ + CHR$(v)
  96.             alt$ = "": AltWasDown = 0
  97.         END IF
  98.         blink = (blink + 1) MOD 30
  99.         LOCATE Y, X
  100.         PRINT LEFT$(in$, CP);
  101.         IF blink \ 15 THEN PRINT " "; ELSE PRINT "_";
  102.         PRINT MID$(in$, CP + 1)
  103.  
  104.         _DISPLAY
  105.         _LIMIT 30
  106.     LOOP UNTIL k = 13
  107.  
  108.     PCOPY 1, 0
  109.     LOCATE Y, X: PRINT in$
  110.     ExtendedInput$ = in$
Without _KEYCLEAR.jpg
* Without _KEYCLEAR.jpg (Filesize: 223.73 KB, Dimensions: 989x953, Views: 162)
Solved.jpg
* Solved.jpg (Filesize: 240.16 KB, Dimensions: 999x973, Views: 154)
* _KEYCLEAR.txt (Filesize: 3.85 KB, Downloads: 124)
« Last Edit: February 05, 2021, 05:19:05 pm by carloscordeiro »

Offline carloscordeiro

  • Forum Regular
  • Posts: 102
    • View Profile
Re: Mr. McNeill's extended entrance
« Reply #37 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
CHR.jpg
* CHR.jpg (Filesize: 236.68 KB, Dimensions: 1124x627, Views: 164)
« Last Edit: February 05, 2021, 07:59:52 pm by carloscordeiro »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Mr. McNeill's extended entrance
« Reply #38 on: February 05, 2021, 07:50:31 pm »
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.

Offline carloscordeiro

  • Forum Regular
  • Posts: 102
    • View Profile
Re: Mr. McNeill's extended entrance
« Reply #39 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"

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Mr. McNeill's extended entrance
« Reply #40 on: February 05, 2021, 07:58:30 pm »
I added _KEYCLEAR Bplus,

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

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

Use
Code: QB64: [Select]
  1. Loop Until _Keydown(27)  ' then don't need INKEY$

Steve might tuck _Keyclear into his ExtendedInput Sub or Function. ;-)) or Carlos could :)
« Last Edit: February 05, 2021, 08:01:27 pm by bplus »

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Mr. McNeill's extended entrance
« Reply #41 on: February 05, 2021, 08:11:50 pm »
ExtendedInput has nothing to do with you being stuck in the loop, and neither does the CHR$(22).

That 22 is coming from you hitting CTRL-V, with INKEY$.  The ExtendedInput uses _KEYHIT exclusively and doesn't touch INKEY$ at all, so all those keypresses you type when using KEYHIT are still stored in the INKEY$ buffer -- which in this case is CHR$(22) or CTRL-V...

_KEYCLEAR clears those buffers, and eliminates that problem completely, but, as  you can see from the below, you're still stuck in an endless loop which you can't break out of:

Code: QB64: [Select]
  1. _TITLE "Qbasic 64"
  2. SCREEN _NEWIMAGE(600, 600, 256)
  3.  
  4.     FOR e = 1 TO 100
  5.         h = h + 1
  6.         IF h > 10 THEN
  7.             COLOR 30: LOCATE 30, 3: PRINT "Press Enter to continue ..."
  8.             DO
  9.                 _LIMIT 30
  10.             LOOP UNTIL INKEY$ = CHR$(13)
  11.             h = 5: j = j + 20
  12.         END IF
  13.         FOR i = 1 TO 30 STEP 2
  14.             x$ = x$ + MID$(a$, i, 2) + " "
  15.         NEXT
  16.         x$ = _TRIM$(x$)
  17.         _LIMIT 60
  18.         LOCATE h, j: PRINT e; "_KEYCLEAR" ' ASC(K$)
  19.     NEXT
  20.     Scrn$ = INKEY$
  21. LOOP UNTIL Scrn$ = CHR$(27)
  22.  
  23.  

Now the reason for this is really rather simple -- you're clearing your INKEY$ buffer here:

Code: [Select]
            DO
                _LIMIT 30
            LOOP UNTIL INKEY$ = CHR$(13)

So it's going to be impossible for that buffer to key any keypresses to read here:

Code: [Select]
    Scrn$ = INKEY$ 


Now, I don't know what you're trying to do with your example here, but that's the issue -- one INKEY$ call clearing the buffer so the other one can only read a blank nothing.

As bplus suggests, swap over to something independent to INKEY$ as your exit, or do something like this:

Code: QB64: [Select]
  1. _TITLE "Qbasic 64"
  2. SCREEN _NEWIMAGE(600, 600, 256)
  3.  
  4. j = 1
  5.     FOR e = 1 TO 100
  6.         h = h + 1
  7.         IF h > 10 THEN
  8.             COLOR 30: LOCATE 30, 3: PRINT "Press Enter to continue ..."
  9.             DO
  10.                 _LIMIT 30
  11.                 Scrn$ = INKEY$
  12.                 IF Scrn$ = CHR$(27) THEN GOTO outside_loop
  13.             LOOP UNTIL Scrn$ = CHR$(13)
  14.             h = 5: j = j + 20
  15.         END IF
  16.         FOR i = 1 TO 30 STEP 2
  17.             x$ = x$ + MID$(a$, i, 2) + " "
  18.         NEXT
  19.         x$ = _TRIM$(x$)
  20.         _LIMIT 60
  21.         LOCATE h, j: PRINT e; "_KEYCLEAR" ' ASC(K$)
  22.     NEXT
  23.     Scrn$ = INKEY$
  24. LOOP UNTIL Scrn$ = CHR$(27)
  25.  
  26. outside_loop:
  27. PRINT "I'm free!  I'm free!  I'm outta those loops!"
  28.  
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Mr. McNeill's extended entrance
« Reply #42 on: February 05, 2021, 08:15:59 pm »
Steve recheck your line #24 & #25

I meant
Code: QB64: [Select]
  1. Loop Until _Keydown(27)  'you don't need INKEY$
  2.  
« Last Edit: February 05, 2021, 08:17:23 pm by bplus »

Offline carloscordeiro

  • Forum Regular
  • Posts: 102
    • View Profile
Re: Mr. McNeill's extended entrance
« Reply #43 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
* Lotofacil V2.txt (Filesize: 8.49 KB, Downloads: 90)
* loto.txt (Filesize: 96.58 KB, Downloads: 86)
« Last Edit: February 05, 2021, 08:26:40 pm by carloscordeiro »

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Mr. McNeill's extended entrance
« Reply #44 on: February 05, 2021, 08:26:02 pm »
you are very funny, Bplus

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

It's not working as it can't be triggered while within the INKEY$ loop...  You have to clear the INKEY$ loop and then hit 27 in the millisecond where you're between falling into it again.

You have to put your exit condition inside that central loop, if ENTER is going to be your only way to stop that manual pause.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!