what i want to try and do is cover up the password with *. for instance when you are entering in the password insteaded of seeing 'program' you would see '*******'. is it possible to do it with only using crt? i havent learnt anything else yet. im a noob at pascal.
this is my program:
[code]
program password_program;
uses crt;
var
password:string;
label pass;
label correct;
label wrong;
label quit;
begin
pass:
clrscr;
writeln('please enter correct password:');
readln(password);
if password='program' then goto correct else goto wrong;
correct:
writeln('correct password! you may continue.');
readln;
goto quit;
wrong:
writeln('bad password! try again!');
readln;
goto pass;
quit:
end.
[/code]
Comments
: instance when you are entering in the password insteaded of seeing
: 'program' you would see '*******'. is it possible to do it with only
: using crt? i havent learnt anything else yet. im a noob at pascal.
:
: this is my program:
:
: [code]:
: program password_program;
: uses crt;
: var
: password:string;
[red]: ch : char ;[/red]
:
: label pass;
: label correct;
: label wrong;
: label quit;
:
: begin
: pass:
: clrscr;
: writeln('please enter correct password:');
[red]
password := '' ; { nul string }
{
readkey does not echo
}
ch := readkey ; { get first character ]
while ord(ch) <> 13 do begin { "ENTER" key exits loop }
password := password + ch ;
write ('*') ; { fake echo }
ch := readkey { get next character }
end ;
writeln ; { fake an echo of the "ENTER" key }
[/red]
:
: if password='program' then goto correct else goto wrong;
:
: correct:
: writeln('correct password! you may continue.');
: readln;
: goto quit;
:
: wrong:
: writeln('bad password! try again!');
: readln;
: goto pass;
:
: quit:
: end.
: [/code]:
: : instance when you are entering in the password insteaded of seeing
: : 'program' you would see '*******'. is it possible to do it with only
: : using crt? i havent learnt anything else yet. im a noob at pascal.
: :
: : this is my program:
: :
: : [code]: :
: : program password_program;
: : uses crt;
: : var
: : password:string;
: [red]: ch : char ;[/red]
: :
: : label pass;
: : label correct;
: : label wrong;
: : label quit;
: :
: : begin
: : pass:
: : clrscr;
: : writeln('please enter correct password:');
: [red]
: password := '' ; { nul string }
: {
: readkey does not echo
: }
: ch := readkey ; { get first character ]
: while ord(ch) <> 13 do begin { "ENTER" key exits loop }
: password := password + ch ;
: write ('*') ; { fake echo }
: ch := readkey { get next character }
: end ;
: writeln ; { fake an echo of the "ENTER" key }
: [/red]
: :
: : if password='program' then goto correct else goto wrong;
: :
: : correct:
: : writeln('correct password! you may continue.');
: : readln;
: : goto quit;
: :
: : wrong:
: : writeln('bad password! try again!');
: : readln;
: : goto pass;
: :
: : quit:
: : end.
: : [/code]: :
:
:
This supports Backspace is case you mistyped
[code][color=Blue]
uses crt;
var pwd:string;
function get_pwd(mask:char):string; {mask can be any printable character}
var ch:char;
s:string;
begin
write('Enter password: ');
s:=''; {password set ot nil}
repeat
ch:=readkey; {read a key}
case ord(ch) of
8:{BckSp} if length(s)>0 then begin
gotoxy(pred(wherex),wherey); {move cursor to left}
write(#32); {print space to erase last char.}
gotoxy(pred(wherex),wherey); {move cursor to left}
if length(s)=1 then s:='' else s:=copy(s,1,pred(length(s)));
{if password length is 1 then set password to nil}
end else write(#7); {Beeps if 0 length}
32..127:{Spc..~}if length(s)<255 then begin
s:=s+ch;
write(mask);
end else write(#7);
end;
until ord(ch)=13; {Enter}
writeln; {CR+LF}
get_pwd:=s;
end;
begin
pwd:=get_pwd('*');
writeln('Password is: ',pwd);
end.
[/color][/code]
:
:
Not with simple pascal commands. But it is possible to remap the whole VGA character set, even to have 512 characters on hand. If you good with assembly, I think I have some code somewhere... On the other hand it's easily done in graphics mode ( settextstyle ).
: :
: :
: Not with simple pascal commands. But it is possible to remap the
: whole VGA character set, even to have 512 characters on hand. If you
: good with assembly, I think I have some code somewhere... On the
: other hand it's easily done in graphics mode ( settextstyle ).
:
hah nevermind then. no problem