Solved

Backspace in Password Field

Posted on 1998-02-13
9
903 Views
Last Modified: 2008-02-26
If i am using a password field in this kind of program, i want to know how to use backspace as a function not as #18/

the ascii charactor would get stored.  how do i make backspace actually backspace?  thanks...()
and if i had "*" echoing, how would i have the * erase?  i need both kind of password erasures....thanks

program getpassword;

uses
  crt;

var
  pass:string;
  c:char;

begin
  clrscr;
  textcolor(lightgray);
  write('Enter your password: ');
  pass:='';
  while c<>chr(13) do
  begin
    c:=readkey;
    if c<>#13 then
    begin
      pass:=pass+c;
    end;
  end;
  writeln;
  write('Status: ');
  textcolor(15);
  if pass = 'abc123' then writeln('Access Granted!')
  else writeln('Access Denied!');
  textcolor(7);
  write('Pass: ');
  textcolor(15);
  writeln(pass);
  textcolor(lightgreen);
  writeln; writeln('Program Terminated.');
  readkey
end.
0
Comment
Question by:weinrj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
9 Comments
 
LVL 2

Accepted Solution

by:
kellyjj earned 20 total points
ID: 1217310
I would use a array of char. Then I would use the loop and readkey to read each individual char.  I would also use 'gotoxy(x,y)' for the location of each char.  This way when a backspace key is hit you can simply write out char (32) to minus 1 from x.
0
 

Author Comment

by:weinrj
ID: 1217311
how can i do that?
0
 
LVL 1

Expert Comment

by:FuzzyLogic
ID: 1217312
Simplier way is to write(#8,' ',#8) when BackSpace is pressed.
This way you don't need the gotoxy(). However, it works fine only if you don't have line-split.
just add an if statement:
  if (c=#8) begin;
    dec(byte(pass[0]));
    write(#8,' ',#8);
    continue;
  end;
0
[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

 
LVL 2

Expert Comment

by:kellyjj
ID: 1217313
while (x<>char(13)) do
begin
  x=readkey();
  if (x<>char(8))
  begin
    pas_ary[y]=x;
    gotoxy(z,y); write("*");
    inc(z);
    inc(y);
  end
  else
  begin
     dec(z);
     gotoxy(z,y); write(" ");
  end;
end
0
 

Author Comment

by:weinrj
ID: 1217314
thank you...i will implement this into my code....
0
 

Author Comment

by:weinrj
ID: 1217315
uh, kelly, can u let me know how to use that code....my project
uses an entirely different way of doing things.  thanks....
0
 

Author Comment

by:weinrj
ID: 1217316
another note....if the cursor is not moving in my program example, how do i backspace the last stored information
0
 
LVL 2

Expert Comment

by:kellyjj
ID: 1217317
could you clearify what you mean by using a different meathod? Also, I would do a search for some assembler tutorials, interrupt listings.  There assembler rountines that control the cursor which are only a few lines.  Knowing assembler would be a great thing since you are using pascal.  I use assembler quite a bit with both pascal and C.
0
 

Author Comment

by:weinrj
ID: 1217318
If this question is directed to me, the only thing i can help you with is cursorOn and cursorOff procedures.  I dont know any asm other than that.  i do want to learn myself, and i hope to learn it soon....

Procedure hideCursor; assembler;

asm
 mov es,[Seg0040]
 mov di,0060h
 mov cx,word ptr es:[di]
 mov ax,0100h
 or  ch,20h
 int 10h
end;

Procedure showCursor; assembler;

asm
 mov es,[Seg0040]
 mov di,0060h
 mov cx,word ptr es:[di]
 mov ax,0100h
 and ch,0dfh
 int 10h
end;


there ya go.....
NOTE:  If you do know assembler, this looks different than the true asm statements.  I had a friend tell me what to do.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Choosing a core focus or particular set of features and options can be tough. To help out, we’re going to highlight a handful of things your business needs on one of your social media pages. In other words, if one of these is missing, you should imp…
Part Two of the two-part Q&A series with MalwareTech.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question