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

0 Members and 1 Guest are viewing this topic.

Offline carloscordeiro

  • Forum Regular
  • Posts: 102
    • View Profile
Mr. McNeill's extended entrance
« on: January 31, 2021, 09:11:06 pm »
Good evening Mr. SMcNeill
The Extended Entry you created is an excellent code.
I had asked bplus about it at: https://www.qb64.org/forum/index.php?topic=3209.msg124899#msg124899.

Very attentive, you showed the post.

Just now, I had time to insert a code of dozens of combinations.

In your post, you mention that the extended entry can be useful.

For me it is being very useful, I can risk saying necessary.

This code resolve the stresses that I had.
1 - exhaustion in entering 44 digits.
2 - Always running the risk of typos.
3 - the duration of registration.

Just as I ask Bplus for a lot of help.

I would very much like you to analyze if my inserted lines comply with your code.
If I made a mistake, I ask you to show me where the error is and how to fix it.

The amount of numbers entered will always be these:
010204060809111316171819202122

Carlos
Code: QB64: [Select]
  1. _TITLE "Qbasic 64"
  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 "* * * LOTOFACIL * * *"
  22. LOCATE 2, 4: PRINT f$
  23. '--------------------------------------------------------------------------------
  24. DIM registration AS LONG
  25.  
  26.  
  27. IF _FILEEXISTS("loto.txt") THEN
  28.     OPEN "loto.txt" FOR INPUT AS #1
  29.     registration = LOF(1) \ 46
  30.     SEEK #1, LOF(1) - 45
  31.     LINE INPUT #1, nt$
  32.     CLOSE
  33.  
  34. LOCATE 25, 3: PRINT "Press [ESC] to exit."
  35. LOCATE 4, 3: PRINT "N" + CHR$(163); "mere contests =>"; registration
  36.  
  37. OPEN "loto.txt" FOR APPEND AS #1
  38.  
  39. 'PRINT ExtendedInput$
  40.  
  41.     LOCATE 6, 14: PRINT "_______________________________"
  42.     LOCATE 6, 3: PRINT "Dozens => ";
  43.     a$ = ExtendedInput$
  44.  
  45.     FOR i = 1 TO 30 STEP 2
  46.         x$ = x$ + MID$(a$, i, 2) + " "
  47.     NEXT
  48.  
  49.     x$ = _TRIM$(x$)
  50.  
  51.     LOCATE 8, 3: PRINT "Dozens => "; x$
  52.     LOCATE 10, 3: PRINT "N" + CHR$(163); "mere digits ="; LEN(x$)
  53.  
  54.     IF LEN(x$) = 44 THEN
  55.         PRINT #1, x$
  56.         LOCATE 12, 3: PRINT "Dozens successfully saved !!!"
  57.     ELSE
  58.         BEEP
  59.     END IF
  60.     x$ = ""
  61.     Scrn$ = INKEY$
  62. LOOP UNTIL Scrn$ = CHR$(27)
  63.  
  64. '--------------------------------------------------------------------------------
  65.  
  66. FUNCTION ExtendedInput$
  67.     PCOPY 0, 1
  68.     A = _AUTODISPLAY: X = POS(0): Y = CSRLIN
  69.     CP = 0: OldCP = 0 'Cursor Position
  70.     _KEYCLEAR
  71.     DO
  72.         PCOPY 1, 0
  73.         IF _KEYDOWN(100307) OR _KEYDOWN(100308) THEN AltDown = -1 ELSE AltDown = 0
  74.         k = _KEYHIT
  75.         IF AltDown THEN
  76.             SELECT CASE k 'ignore all keypresses except ALT-number presses
  77.                 CASE 48 TO 57: AltWasDown = -1: alt$ = alt$ + CHR$(k)
  78.             END SELECT
  79.         ELSE
  80.             SELECT CASE k 'without alt, add any keypresses to our input
  81.                 CASE 8
  82.                     oldin$ = in$
  83.                     IF CP > 0 THEN OldCP = CP: CP = CP - 1
  84.                     in$ = LEFT$(in$, CP) + MID$(in$, CP + 2) 'backspace to erase input
  85.                 CASE 9
  86.                     oldin$ = in$
  87.                     in$ = LEFT$(in$, CP) + SPACE$(4) + MID$(in$, CP + 1) 'four spaces for any TAB entered
  88.                     OldCP = CP
  89.                     CP = CP + 4
  90.                 CASE 32 TO 128
  91.                     IF _KEYDOWN(100305) OR _KEYDOWN(100306) THEN
  92.                         IF k = 118 OR k = 86 THEN
  93.                             oldin$ = in$
  94.                             in$ = LEFT$(in$, CP) + _CLIPBOARD$ + MID$(in$, CP + 1) 'ctrl-v paste
  95.                             'CTRL-V leaves cursor in position before the paste, without moving it after.
  96.                             'Feel free to modify that behavior here, if you want it to move to after the paste.
  97.                         END IF
  98.                         IF k = 122 OR k = 90 THEN SWAP in$, oldin$: SWAP OldCP, CP 'ctrl-z undo
  99.                     ELSE
  100.                         oldin$ = in$
  101.                         in$ = LEFT$(in$, CP) + CHR$(k) + MID$(in$, CP + 1) 'add input to our string
  102.                         OldCP = CP
  103.                         CP = CP + 1
  104.                     END IF
  105.                 CASE 18176 'Home
  106.                     CP = 0
  107.                 CASE 20224 'End
  108.                     CP = LEN(in$)
  109.                 CASE 21248 'Delete
  110.                     oldin$ = in$
  111.                     in$ = LEFT$(in$, CP) + MID$(in$, CP + 2)
  112.                 CASE 19200 'Left
  113.                     CP = CP - 1
  114.                     IF CP < 0 THEN CP = 0
  115.                 CASE 19712 'Right
  116.                     CP = CP + 1
  117.                     IF CP > LEN(in$) THEN CP = LEN(in$)
  118.             END SELECT
  119.         END IF
  120.         alt$ = RIGHT$(alt$, 3)
  121.         IF AltWasDown = -1 AND AltDown = 0 THEN
  122.             v = VAL(alt$)
  123.             IF v >= 0 AND v <= 255 THEN in$ = in$ + CHR$(v)
  124.             alt$ = "": AltWasDown = 0
  125.         END IF
  126.         blink = (blink + 1) MOD 30
  127.         LOCATE Y, X
  128.         PRINT LEFT$(in$, CP);
  129.         IF blink \ 15 THEN PRINT " "; ELSE PRINT "_";
  130.         PRINT MID$(in$, CP + 1)
  131.  
  132.         _DISPLAY
  133.         _LIMIT 30
  134.     LOOP UNTIL k = 13
  135.  
  136.     PCOPY 1, 0
  137.     LOCATE Y, X: PRINT in$
  138.     ExtendedInput$ = in$
* Cadastro V1.txt (Filesize: 4.61 KB, Downloads: 123)
* loto.txt (Filesize: 96.45 KB, Downloads: 123)
Entrada estendida_01.jpg
* Entrada estendida_01.jpg (Filesize: 145.24 KB, Dimensions: 785x1021, Views: 212)
Entrada estendida_02.jpg
* Entrada estendida_02.jpg (Filesize: 179.4 KB, Dimensions: 1037x969, Views: 206)

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Mr. McNeill's extended entrance
« Reply #1 on: February 01, 2021, 12:56:56 am »
Hi @carloscordeiro

I can't tell if you are asking a question or thanking Mr SMcNeill.

I would be thanking him because I copy & pasted that set of numbers from forum with Ctrl + V into the code you had and got same results as you show. That's good because I'd sure hate to type all that stuff! :) As you say, a time saver and stress relief.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Mr. McNeill's extended entrance
« Reply #2 on: February 01, 2021, 01:11:50 am »
Looks to me like it’s working as intended. 

I’m happy to see it suit your needs.  Just let me know if there’s any unexpected glitches with it.  :)
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 #3 on: February 01, 2021, 05:01:52 pm »
Hi Bplus,

I am very grateful to Mr. SMcNeill for his contributions to this forum.

thankful yet but for the excellent extended entry code.

Você sabe que serei sempre grato a todo deste forum.

I believe that I did not make my gratitude very clear, due to the question.

I'll do it more clearly.
On line 49 "a $ = ExtendedInput $".

I was unable to separate the variable "A $" from "ExtendedInput $"

That's why I asked Mr. SMcNeill to analyze if there is any error on my part.

I was not careful to explain which line was my mistake.

Thank you in advance, Mr. SMcNeill for the excellent code.

Carlos

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Mr. McNeill's extended entrance
« Reply #4 on: February 01, 2021, 05:19:19 pm »
Hi Bplus,

I am very grateful to Mr. SMcNeill for his contributions to this forum.

thankful yet but for the excellent extended entry code.

Você sabe que serei sempre grato a todo deste forum.

I believe that I did not make my gratitude very clear, due to the question.

I'll do it more clearly.
On line 49 "a $ = ExtendedInput $".

I was unable to separate the variable "A $" from "ExtendedInput $"

That's why I asked Mr. SMcNeill to analyze if there is any error on my part.

I was not careful to explain which line was my mistake.

Thank you in advance, Mr. SMcNeill for the excellent code.

Carlos

So the screen shots you showed were from doing the ExtendedInput$ the hard way by hand typing all those numbers?

OK Steve may have more to add but let's cover the basic's
1. I assume you want to enter the contents of a clipboard copy and you have the number copied for a paste.
2. You have the code loaded and running.
3. You clicked that window with your code running AGAIN
      + after loading the copy to paste you click the code screen again so that screen now has the focus.
4. I may of clicked the blank line again just to be sure the paste was going where I intended
5. You pressed the Key combination Ctrl + V
6 Oh press enter just like a normal input enter, maybe that's what you are missing? need to press enter to signal when you are done inputting.
7. the paste should now magically appear?

Quote
'CTRL+V leaves cursor in position before the paste, without moving it after.

I just checked 2 more times and your code made this in loto.txt file:
Quote
01 02 04 06 08 09 11 13 16 17 18 19 20 21 22
01 02 04 06 08 09 11 13 16 17 18 19 20 21 22


EDIT: sorry I missed the last step press enter!


« Last Edit: February 01, 2021, 05:37:54 pm by bplus »

Offline carloscordeiro

  • Forum Regular
  • Posts: 102
    • View Profile
Re: Mr. McNeill's extended entrance
« Reply #5 on: February 01, 2021, 05:34:21 pm »
Bplus, the code is perfect, The question I asked, it doesn't aggravate.

I just thought that I had done something wrong so that "A$" could not be separated.

Image shows what I am trying to express.

I am happy even using the semicolon.

Once again, thank you very much Mr. SMcNeill.

Carlos
Separar.jpg
* Separar.jpg (Filesize: 182.53 KB, Dimensions: 999x751, Views: 154)

Offline carloscordeiro

  • Forum Regular
  • Posts: 102
    • View Profile
Re: Mr. McNeill's extended entrance
« Reply #6 on: February 01, 2021, 05:50:05 pm »
"I just checked 2 more times and your code made this in loto.txt file:"

"EDIT: sorry I missed the last step press enter!"


I didn't understand, Bplus

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Mr. McNeill's extended entrance
« Reply #7 on: February 01, 2021, 05:54:29 pm »
Quote
I'll do it more clearly.
On line 49 "a $ = ExtendedInput $".

I was unable to separate the variable "A $" from "ExtendedInput $"

I'm not entirely certain what you're asking here.  ExtendedInput is a FUNCTION, so it's going to always behave like a function.  Think of it like the math command for absolute values -- it can't just sit in your code by itself, doing nothing.

You can:

PRINT ABS(-2)

OR

X = X + ABS(-2)

But you can't just toss in a stray:

ABS(-2)



FUNCTIONS aren't stand alone commands.  They require something to interact with and to receive their value.

SUBS, on the other hand, can be stand-alone commands, like CLS, PRINT, or END. 

Since ExtendedInput is a function, it has to have a variable to send its information to, thus the A$ = ExtendedInput is required.  (Or at least some string variable is.  You can change A$ to Whatever$ if you like, and it'd suit your needs better.)

If you're looking for a way to turn A$ into A (as a number), then you'd want to take the VAL of the ExtendedInput.

A = VAL(ExtendedInput)

Though, with the way you're entering and adding spaces to the values, I really don't think that's what you're wanting to do...

Are you trying to turn that long string into an array of 15 Numbers?  If so, you'd just use VAL of the MID$, like you did on line 52 when you inserted the spaces for readability, and assign the values then to your array.

Like I say, I'm not completely certain what you're asking, or what you're trying to do.  What's the purpose in "separating the variable a$ from ExtendedInput?  What are you trying to Accomplish?



Could the solution be as simple as:

DIM A AS STRING 'Place at top of code.

A = ExtendedInput 'no need for $
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 #8 on: February 01, 2021, 06:03:37 pm »
"I just checked 2 more times and your code made this in loto.txt file:"

"EDIT: sorry I missed the last step press enter!"


I didn't understand, Bplus

OK I copy number to clipboard.
I click the the screen with your running program.
I then press Ctrl and V at the same time
the copy of the unseparated numbers cover the blank line
I press the enter button sometimes called the return button
the blank line is back but the numbers are now 2 lines down all separated as shown in the loto.txt file.

Looks good to me, I did a couple more times and the file is loading up with copies of that separated number.

Offline carloscordeiro

  • Forum Regular
  • Posts: 102
    • View Profile
Re: Mr. McNeill's extended entrance
« Reply #9 on: February 01, 2021, 06:12:44 pm »
As I already said, Mr. SMcNeill. I am very satisfied with your code.

I always express myself badly.

I'll try again:
This is what I did to show the cursor after "=> '
     LOCATE 6, 3: PRINT "Dozens =>";
     a $ = ExtendedInput $

I tried to do this:
  a $ = ExtendedInput $
LOCATE 6, 3: PRINT "Dozens =>"; a $
  Did not work

Now I know that ExtendedInput is a FUNCTION.

Always grateful to you.

Carlos
« Last Edit: February 01, 2021, 06:20:36 pm by carloscordeiro »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Mr. McNeill's extended entrance
« Reply #10 on: February 01, 2021, 06:20:00 pm »
As I already said, Mr. SMcNeill. I am very satisfied with your code.

I always express myself badly.

I'll try again:
This is what I did to make the cursor look after "=> '
     LOCATE 6, 3: PRINT "Dozens =>";
     a $ = ExtendedInput $

I tried to do this:
  a $ = ExtendedInput $
LOCATE 6, 3: PRINT "Dozens =>"; a $
  Did not work

Now I know that ExtendedInput is a FUNCTION.

Always grateful to you.

Carlos

Well you are throwing me off with the $ separated from variable or function

But if you want to see the pasted text after Ctrl V do so BEFORE you press enter, you will see it on line 6 in it's raw form before the rest of the code gets to it, separates it and then loops around and redraws the line for the next thing to input.

Offline carloscordeiro

  • Forum Regular
  • Posts: 102
    • View Profile
Re: Mr. McNeill's extended entrance
« Reply #11 on: February 01, 2021, 06:34:19 pm »
Bplus, is the translator who is separating the $ from the variable.

I am not able to express it correctly.

But it's all right.

"It looks good to me, I did it a few more times and the file is carrying copies of that separate number."

Here's saving without a copy.

Two images so that there is no question left.

As Mr. SMcNeill said, ExtendedInput should be constantly reading ...

Carlos
Cursor_01.jpg
* Cursor_01.jpg (Filesize: 116.93 KB, Dimensions: 730x686, Views: 185)
Cursor_02.jpg
* Cursor_02.jpg (Filesize: 147.37 KB, Dimensions: 897x893, Views: 148)
« Last Edit: February 01, 2021, 07:08:47 pm by carloscordeiro »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Mr. McNeill's extended entrance
« Reply #12 on: February 01, 2021, 07:31:50 pm »
Quote
Curses foiled again ;(

Translation, it seems if you start typing something after you paste in the number and before you press enter, that text ends up before the pasted in number or text. That's not good. The curser should appear after the pasted in text.

Is that it Carlos? The curser is in the wrong place after the paste.
Curses foiled again.PNG
* Curses foiled again.PNG (Filesize: 7.16 KB, Dimensions: 600x213, Views: 156)
« Last Edit: February 01, 2021, 07:46:39 pm by bplus »

FellippeHeitor

  • Guest
Re: Mr. McNeill's extended entrance
« Reply #13 on: February 01, 2021, 07:38:28 pm »
Oi, Carlos. Às vezes a gente se perde mesmo na tradução. Não sei se sua pergunta já foi respondida, mas posso te ajudar com algo? Já que falamos a mesma língua, podemos nos ser mutuamente úteis.

Abraço!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Mr. McNeill's extended entrance
« Reply #14 on: February 01, 2021, 07:47:31 pm »
Quote
Curses foiled again ;(

Translation, it seems if you start typing something after you paste in the number and before you press enter, that text ends up before the pasted in number or text. That's not good. The curser should appear after the pasted in text.

Is that it Carlos? The curser is in the wrong place after the paste.