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
'CTRL+V leaves cursor in position before the paste, without moving it after.
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
I'll do it more clearly.
On line 49 "a $ = ExtendedInput $".
I was unable to separate the variable "A $" from "ExtendedInput $"
"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
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
Curses foiled again ;(
Curses foiled again ;(
SUB ExtendedInput (prompt$, result$)
PCOPY 0, 1
A = _AUTODISPLAY: X = POS(0): Y = CSRLIN
CP = 0: OldCP = 0 'Cursor Position
_KEYCLEAR
DO
PCOPY 1, 0
IF _KEYDOWN(100307) OR _KEYDOWN(100308) THEN AltDown = -1 ELSE AltDown = 0
k = _KEYHIT
IF AltDown THEN
SELECT CASE k 'ignore all keypresses except ALT-number presses
CASE 48 TO 57: AltWasDown = -1: alt$ = alt$ + CHR$(k)
END SELECT
ELSE
SELECT CASE k 'without alt, add any keypresses to our input
CASE 8
oldin$ = in$
IF CP > 0 THEN OldCP = CP: CP = CP - 1
in$ = LEFT$(in$, CP) + MID$(in$, CP + 2) 'backspace to erase input
CASE 9
oldin$ = in$
in$ = LEFT$(in$, CP) + SPACE$(4) + MID$(in$, CP + 1) 'four spaces for any TAB entered
OldCP = CP
CP = CP + 4
CASE 32 TO 128
IF _KEYDOWN(100305) OR _KEYDOWN(100306) THEN
IF k = 118 OR k = 86 THEN
oldin$ = in$
in$ = LEFT$(in$, CP) + _CLIPBOARD$ + MID$(in$, CP + 1) 'ctrl-v paste
'CTRL-V leaves cursor in position before the paste, without moving it after.
'Feel free to modify that behavior here, if you want it to move to after the paste.
END IF
IF k = 122 OR k = 90 THEN SWAP in$, oldin$: SWAP OldCP, CP 'ctrl-z undo
ELSE
oldin$ = in$
in$ = LEFT$(in$, CP) + CHR$(k) + MID$(in$, CP + 1) 'add input to our string
OldCP = CP
CP = CP + 1
END IF
CASE 18176 'Home
CP = 0
CASE 20224 'End
CP = LEN(in$)
CASE 21248 'Delete
oldin$ = in$
in$ = LEFT$(in$, CP) + MID$(in$, CP + 2)
CASE 19200 'Left
CP = CP - 1
IF CP < 0 THEN CP = 0
CASE 19712 'Right
CP = CP + 1
IF CP > LEN(in$) THEN CP = LEN(in$)
END SELECT
END IF
alt$ = RIGHT$(alt$, 3)
IF AltWasDown = -1 AND AltDown = 0 THEN
v = VAL(alt$)
IF v >= 0 AND v <= 255 THEN in$ = in$ + CHR$(v)
alt$ = "": AltWasDown = 0
END IF
blink = (blink + 1) MOD 30
LOCATE Y, X
PRINT prompt$; LEFT$(in$, CP);
IF blink \ 15 THEN PRINT " "; ELSE PRINT "_";
PRINT MID$(in$, CP + 1)
_DISPLAY
_LIMIT 30
LOOP UNTIL k = 13
PCOPY 1, 0
LOCATE Y, X: PRINT prompt$, in$
Result$ = in$
IF A THEN _AUTODISPLAY
END FUNCTION
Oh ha! just wanted a FUNCTION turned into a SUB. I always thought INPUT would be more correct as a FUNCTON because you expect it to return a value.
Well Steve nice try but you cant sneak in anything new with all these old traditionalists hanging about ;-))
The problem was the semicolon after the PRINT statement. Carlos wanted a 1 line solution, rather than having it on two lines.
This was bad:
PRINT “Dozens => “;
a$ = ExtendedInput$
This is good:
ExtendedInput “Dozens => “, a$
See? There’s no annoying, dangling semicolon at the end of the second version.
Carlos just wanted it all on a single line to suit his coding style. ;D
(Though I do wonder why a colon wouldn’t have worked just as well? PRINT “Dozens => “;: a$ = ExtendedInput)
CTRL-V to paste, then hit the END key to move to the end of the text. ;)Ok, Bplus, I no longer wanted to disturb Mr. SMcNeill.
Or, modify the code where the comment is about CTRL-V not moving the cursor. Just add:
CP = CP + LEN(_CLIPBOARD$)
Well now I know what language to translate from:
All right, I added line 121
And, if folks need something else added to this, feel free to speak up while I'm still at home and have a few days where I don't have to take care of mom. (Which gives you the next 3 days, or so, to make requests for additions/alterations.)
QuoteE, se as pessoas precisarem de algo mais adicionado a isso, fique à vontade para falar enquanto ainda estou em casa e ter alguns dias sem ter que cuidar da mãe. (O que dá a você os próximos 3 dias, ou mais, para fazer solicitações de acréscimos / alterações.)
Boa noite Sr. SMcNeill
Criei outro cenário para o seu código, o que me deixou muito feliz.
Nesse cenário, notei que o buffer do teclado possui o caractere “22”, além das 30 dezenas.
Ele está fazendo o loop dar duas voltas antes de parar.
Ele continua a ignorar a linha se h> 10 Então pare.
Imagem e código de exemplo.
CarlosCode: QB64: [Select]
_TITLE "Qbasic 64" _DELAY .25 'PRINT ExtendedInput$ a$ = ExtendedInput$ h = 4 j = 2 K$ = INKEY$ h = h + 1 _LIMIT 30 h = 5: j = 25 _LIMIT 60 Scrn$ = INKEY$ FUNCTION ExtendedInput$ CP = 0: OldCP = 0 'Cursor Position k = _KEYHIT CASE 8 oldin$ = in$ CASE 9 oldin$ = in$ OldCP = CP CP = CP + 4 oldin$ = in$ 'CTRL-V leaves cursor in position before the paste, without moving it after. 'Feel free to modify that behavior here, if you want it to move to after the paste. oldin$ = in$ OldCP = CP CP = CP + 1 CP = 0 oldin$ = in$ CP = CP - 1 CP = CP + 1 alt$ = "": AltWasDown = 0 LOCATE Y, X _LIMIT 30 ExtendedInput$ = in$
Hi Carlos,
I'm still here but this looks to me a note addressed to Steve, so I let it alone.
.
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.
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.
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.
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"
DO
_LIMIT 30
LOOP UNTIL INKEY$ = CHR$(13)
Scrn$ = INKEY$
ou Carlos poderia :)
you are very funny, Bplus
the Loop until _Keydown (27) didn't work.
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.
It's rigged to do 100 repeated things before even exiting and checking the outside loop,Bplus, perform very well by holding the ESC key while pressing ENTER
_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:
'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)
'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)
Glad you have it worked out Carlos, beats me what you were up to! :)