QB64 Phoenix Edition
Silent pw entry not working - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3)
+---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10)
+---- Thread: Silent pw entry not working (/showthread.php?tid=1264)

Pages: 1 2 3 4 5


Silent pw entry not working - Ra7eN - 12-11-2022

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


RE: Silent pw entry not working - NasaCow - 12-11-2022

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!


RE: Silent pw entry not working - Ra7eN - 12-11-2022

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??


RE: Silent pw entry not working - Pete - 12-11-2022

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


RE: Silent pw entry not working - mnrvovrfc - 12-11-2022

(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"
???


RE: Silent pw entry not working - Pete - 12-11-2022

(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


RE: Silent pw entry not working - Ra7eN - 12-11-2022

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!!


RE: Silent pw entry not working - Ra7eN - 12-11-2022

(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


RE: Silent pw entry not working - Pete - 12-11-2022

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

Pete


RE: Silent pw entry not working - RhoSigma - 12-11-2022

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.