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

0 Members and 1 Guest are viewing this topic.

Offline carloscordeiro

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

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Mr. McNeill's extended entrance
« Reply #46 on: February 05, 2021, 09:13:52 pm »
Sorry Carlos I should have checked with a run, I am not quite understanding why that change wouldn't have worked. I have to look it over again.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Mr. McNeill's extended entrance
« Reply #47 on: February 05, 2021, 09:23:23 pm »
Sorry Carlos I should have checked with a run, I am not quite understanding why that change wouldn't have worked. I have to look it over again.

You dont have time between loops to press ESC, before you’re stuck in the “Waiting for ENTER” loop.  That inner loop is trapping everything.
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 #48 on: February 05, 2021, 09:27:53 pm »
What if we stick a _Limit in there and give the CPU fan a break?

I've yet to run the dang thing! :(

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Mr. McNeill's extended entrance
« Reply #49 on: February 05, 2021, 09:46:40 pm »
It’s like this:


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


You’d have to hold ESC while pressing ENTER to avoid falling directly back into that inner loop.
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 #50 on: February 05, 2021, 09:54:26 pm »
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:

Code: QB64: [Select]
  1.  
  2. _Title "Qbasic 64"
  3. Screen _NewImage(600, 600, 256)
  4. _Delay .25
  5.  
  6.  
  7. 'PRINT ExtendedInput$
  8.  
  9. Locate 2, 14: Print "_______________________________"
  10. Locate 2, 3: Print "Dozens => ";
  11. a$ = ExtendedInput$
  12.  
  13. _KeyClear '_KEYCLEAR solved the problem of the intrusive ASCII code 22.
  14.  
  15. h = 4
  16. j = 2
  17. K$ = InKey$
  18.     e = 0
  19.     While _KeyDown(27) = 0
  20.         e = e + 1
  21.         If e > 100 Then Exit While
  22.         h = h + 1
  23.         If h > 10 Then
  24.             Color 30: Locate 30, 3: Print "Press Enter to continue ..."
  25.             Do
  26.                 _Limit 30
  27.             Loop Until InKey$ = Chr$(13)
  28.             h = 5: j = j + 20
  29.         End If
  30.         For i = 1 To 30 Step 2
  31.             x$ = x$ + Mid$(a$, i, 2) + " "
  32.         Next
  33.         x$ = _Trim$(x$)
  34.         _Limit 60
  35.         Locate h, j: Print e; "_KEYCLEAR" ' ASC(K$)
  36.     Wend
  37.  
  38.  
  39. Function ExtendedInput$
  40.     PCopy 0, 1
  41.     A = _AutoDisplay: X = Pos(0): Y = CsrLin
  42.     CP = 0: OldCP = 0 'Cursor Position
  43.     _KeyClear
  44.     Do
  45.         PCopy 1, 0
  46.         If _KeyDown(100307) Or _KeyDown(100308) Then AltDown = -1 Else AltDown = 0
  47.         k = _KeyHit
  48.         If AltDown Then
  49.             Select Case k 'ignore all keypresses except ALT-number presses
  50.                 Case 48 TO 57: AltWasDown = -1: alt$ = alt$ + Chr$(k)
  51.             End Select
  52.         Else
  53.             Select Case k 'without alt, add any keypresses to our input
  54.                 Case 8
  55.                     oldin$ = in$
  56.                     If CP > 0 Then OldCP = CP: CP = CP - 1
  57.                     in$ = Left$(in$, CP) + Mid$(in$, CP + 2) 'backspace to erase input
  58.                 Case 9
  59.                     oldin$ = in$
  60.                     in$ = Left$(in$, CP) + Space$(4) + Mid$(in$, CP + 1) 'four spaces for any TAB entered
  61.                     OldCP = CP
  62.                     CP = CP + 4
  63.                 Case 32 TO 128
  64.                     If _KeyDown(100305) Or _KeyDown(100306) Then
  65.                         If k = 118 Or k = 86 Then
  66.                             oldin$ = in$
  67.                             in$ = Left$(in$, CP) + _Clipboard$ + Mid$(in$, CP + 1) 'ctrl-v paste
  68.                             'CTRL-V leaves cursor in position before the paste, without moving it after.
  69.                             'Feel free to modify that behavior here, if you want it to move to after the paste.
  70.                             CP = CP + Len(_Clipboard$)
  71.                         End If
  72.                         If k = 122 Or k = 90 Then Swap in$, oldin$: Swap OldCP, CP 'ctrl-z undo
  73.                     Else
  74.                         oldin$ = in$
  75.                         in$ = Left$(in$, CP) + Chr$(k) + Mid$(in$, CP + 1) 'add input to our string
  76.                         OldCP = CP
  77.                         CP = CP + 1
  78.                     End If
  79.                 Case 18176 'Home
  80.                     CP = 0
  81.                 Case 20224 'End
  82.                     CP = Len(in$)
  83.                 Case 21248 'Delete
  84.                     oldin$ = in$
  85.                     in$ = Left$(in$, CP) + Mid$(in$, CP + 2)
  86.                 Case 19200 'Left
  87.                     CP = CP - 1
  88.                     If CP < 0 Then CP = 0
  89.                 Case 19712 'Right
  90.                     CP = CP + 1
  91.                     If CP > Len(in$) Then CP = Len(in$)
  92.             End Select
  93.         End If
  94.         alt$ = Right$(alt$, 3)
  95.         If AltWasDown = -1 And AltDown = 0 Then
  96.             v = Val(alt$)
  97.             If v >= 0 And v <= 255 Then in$ = in$ + Chr$(v)
  98.             alt$ = "": AltWasDown = 0
  99.         End If
  100.         blink = (blink + 1) Mod 30
  101.         Locate Y, X
  102.         Print Left$(in$, CP);
  103.         If blink \ 15 Then Print " "; Else Print "_";
  104.         Print Mid$(in$, CP + 1)
  105.  
  106.         _Display
  107.         _Limit 30
  108.     Loop Until k = 13
  109.  
  110.     PCopy 1, 0
  111.     Locate Y, X: Print in$
  112.     ExtendedInput$ = in$
  113.  
  114.  
« Last Edit: February 05, 2021, 10:00:43 pm by bplus »

Offline carloscordeiro

  • Forum Regular
  • Posts: 102
    • View Profile
Re: Mr. McNeill's extended entrance
« Reply #51 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
CHR 13_01.jpg
* CHR 13_01.jpg (Filesize: 135.65 KB, Dimensions: 1047x649, Views: 222)
CHR 13_02.jpg
* CHR 13_02.jpg (Filesize: 118.35 KB, Dimensions: 1179x571, Views: 230)
Repetir.jpg
* Repetir.jpg (Filesize: 374.2 KB, Dimensions: 847x979, Views: 236)
« Last Edit: February 06, 2021, 07:17:00 pm by carloscordeiro »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Mr. McNeill's extended entrance
« Reply #52 on: February 06, 2021, 09:10:29 pm »
Glad you have it worked out Carlos, beats me what you were up to!  :)

Offline NOVARSEG

  • Forum Resident
  • Posts: 509
    • View Profile
Re: Mr. McNeill's extended entrance
« Reply #53 on: February 06, 2021, 10:22:46 pm »
carloscordeiro

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)

« Last Edit: February 06, 2021, 10:24:16 pm by NOVARSEG »

Offline carloscordeiro

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

« Last Edit: February 07, 2021, 05:08:04 pm by carloscordeiro »