Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Backspace in Password Field

Posted on 1998-02-13
9
Medium Priority
?
913 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 80 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
On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

 
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying 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

A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
The core idea of this article is to make you acquainted with the best way in which you can export Exchange mailbox to PST format.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

715 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