Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Silent pw entry not working
#1
Question 
The following code does the following
prints "*" when entering a password (scratch built) and then return the plaintext back.

Instead it returns a zero and blank text. What did I miss? thanks.



Code: (Select All)
Print "-Enter Password: "; pInput$ = silentInput$

    Print pInput$ 'DEBUG DELETE AFTER TESTING


Code: (Select All)
Function silentInput$

    Dim Txt$
    Dim KeyPress$

    Txt$ = ""
    ' GREAT FOR PASSWORDS
    Do
        Do: KeyPress$ = InKey$: Loop Until KeyPress$ > ""
        If KeyPress$ <> Chr$(13) Then
            Txt$ = Txt$ + KeyPress$
            Print "*"; ' crate a visual
        End If

    Loop Until KeyPress$ = Chr$(13)

    Print
    silentInput$ = Txt$
End Function

PS, appreciate you guys keeping the qb64 going!! thank you
3 out of 2 people have trouble with fractions

Reply
#2
Adding a colon will fix it or a new line. Not sure why but it did!

Code: (Select All)
PRINT "-Enter Password: ";: pInput$ = silentInput$  

or

Code: (Select All)
PRINT "-Enter Password: ";
pInput$ = silentInput$

Good luck!
Reply
#3
YES! that does work.
And I think I know why.

silentInput$ is a variable and I am still "printing" the var - it would seem to be similar to using

input "some text: ";a$



I think LOL


beuler, beuler??
3 out of 2 people have trouble with fractions

Reply
#4
Adding the colon is the same as separating the silentInput$ statement from the PRINT statement. So why does it need to be separated? Well, it's because that semi-colon ";" after the PRINT statement is telling PRINT you want to include IF pInput$ = silentInput$ to it. Like Ra7eN figured out, that's a variable comparison expression when it is used that way.

PRINT a = b' That would be false, so it returns zero.

PRINT "Pete" = "Steve" ' That would be false, so it returns zero.

PRINT "Pete" > "Steve" ' Well, that's a story for another time! Big Grin

So even though it still successfully calls the function, it isn't assigning the string variable pInput$ to the function return, it's comparing the null string pInput$ to the results of the the function. So it will always print "0" unless you just hit Enter without typing, which would return a -1, since a null string and an empty string are the same thing.

Pete
Fake News + Phony Politicians = Real Problems

Reply
#5
(12-11-2022, 02:06 PM)Ra7eN Wrote: PS, appreciate you guys keeping the qb64 going!! thank you
Welcome to the forums. You made Pete change away from his cowboy clothes into three-piece suit and back. Now let me see if I could remember that Looney Tunes episode... it must have been the "Wentworth" one ROFLMAO.

Wait, but not:
Code: (Select All)
PRINT "PETE" > "steve"
???
Reply
#6
(12-11-2022, 03:44 PM)mnrvovrfc Wrote:
(12-11-2022, 02:06 PM)Ra7eN Wrote: PS, appreciate you guys keeping the qb64 going!! thank you
Welcome to the forums. You made Pete change away from his cowboy clothes into three-piece suit and back. Now let me see if I could remember that Looney Tunes episode... it must have been the "Wentworth" one ROFLMAO.

Wait, but not:
Code: (Select All)
PRINT "PETE" > "steve"
???

Well, apparently another time is here...

I've long said that's a bug in QB64...

First, let's change what you wrote to...

PRINT "pete" > "STEVE"

But wait, that dog won't hunt... "Expected variable required after =..." [Syntax error message].

So we have to go to the extra work and code...

a$ = "Pete"
b$ = "Steve"
PRINT a$ > b$
'output -1


Hey wait. TARNATION, that' still buggy!!! Big Grin

Pete
Reply
#7
MAN I FEEL LIKE A MORON LOL

that ":" was becasue (after a 2nd look) it was a completely different command (assignment)

Im such a ":"


:-D


btw
Im old school, just had to remake an account!


but glad to be back!!
3 out of 2 people have trouble with fractions

Reply
#8
(12-11-2022, 05:03 PM)Pete Wrote:
(12-11-2022, 03:44 PM)mnrvovrfc Wrote:
(12-11-2022, 02:06 PM)Ra7eN Wrote: PS, appreciate you guys keeping the qb64 going!! thank you
Welcome to the forums. You made Pete change away from his cowboy clothes into three-piece suit and back. Now let me see if I could remember that Looney Tunes episode... it must have been the "Wentworth" one ROFLMAO.

Wait, but not:
Code: (Select All)
PRINT "PETE" > "steve"
???

Well, apparently another time is here...

I've long said that's a bug in QB64...

First, let's change what you wrote to...

PRINT "pete" > "STEVE"

But wait, that dog won't hunt... "Expected variable required after =..." [Syntax error message].

So we have to go to the extra work and code...

a$ = "Pete"
b$ = "Steve"
PRINT a$ > b$
'output -1


Hey wait. TARNATION, that' still buggy!!! Big Grin

Pete


cant be STEVE=UCASE
pete = LCASE

therefore STEVE > pete :-D
3 out of 2 people have trouble with fractions

Reply
#9
We do have fun around here. My excuse is I was too much Star Trek, and have a warped sense of humor.

Pete
Fake News + Phony Politicians = Real Problems

Reply
#10
I never understood the sense of a silent/hidden (or what ever you wanna call) input field.

Simply don't type your password if too many suspicious creatures hanging around you.

And..., if I would be one of those creatures, then I would follow your fingers on the keyboard, so you should better get a keyboard with blank keys instead.
Reply




Users browsing this thread: 3 Guest(s)