Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

[SOLVED] program close automatically


  • Please log in to reply
8 replies to this topic

#1 rrwe

rrwe

    CC Lurker

  • Member
  • Pip
  • 9 posts

Posted 28 August 2012 - 08:02 AM

hi all:)
i am dealing with the following program.
Once I finished to input a correct password, the program will be close automatically.
I 've tried many times and Im still cannot solve it.
Please help me! Thanks a lot!

----------------problem solved. thank you-----------------------
  • 0

#2 lespauled

lespauled

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1360 posts
  • Programming Language:C, C++, C#, JavaScript, PL/SQL, Delphi/Object Pascal, Visual Basic .NET, Pascal, Transact-SQL, Bash

Posted 28 August 2012 - 09:18 AM

It's been a while, but isn't there an exit function that takes an exit status variable?

like: Exit(0); ?
  • 0
My Blog: http://forum.codecal...699-blog-77241/
"Women and Music: I'm always amazed by other people's choices." - David Lee Roth

#3 rrwe

rrwe

    CC Lurker

  • Member
  • Pip
  • 9 posts

Posted 28 August 2012 - 09:32 AM

that's mean i cannot use repeat..until statement?
  • 0

#4 lespauled

lespauled

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1360 posts
  • Programming Language:C, C++, C#, JavaScript, PL/SQL, Delphi/Object Pascal, Visual Basic .NET, Pascal, Transact-SQL, Bash

Posted 28 August 2012 - 09:58 AM

Exit terminates the program, or you can use break to get out of the loop.

Another thing you might want to consider is removing that "if" statement for each character and get the ascii - 64 for each uppercase of the character. Eliminates a ton of code.
  • 0
My Blog: http://forum.codecal...699-blog-77241/
"Women and Music: I'm always amazed by other people's choices." - David Lee Roth

#5 rrwe

rrwe

    CC Lurker

  • Member
  • Pip
  • 9 posts

Posted 28 August 2012 - 10:10 AM

I'm a pascal programming beginner. Having limited knowledge about about it. :(
Is it the solution for solving the problem of the program will be close automatically after imputing a correct password,
Thanks for help
  • 0

#6 Luthfi

Luthfi

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1320 posts
  • Programming Language:PHP, Delphi/Object Pascal, Pascal, Transact-SQL
  • Learning:C, Java, PHP

Posted 30 September 2012 - 06:09 AM

If after the correct password is entered your code gets to the end of the program it simply will be terminated. So you can "protect" the program from termination while incorrect password is entered by encapsulating the pasword entering and checking in a loop.

Something like this is enough.

begin
  PasswordOK := False;
  repeat
    Write('Enter Password: ');
    ReadLn(Password);
    PasswordOK := Check(Password);
    if not PasswordOK then
      WriteLn('Incorrect Password');
  until PasswordOK;
end;

  • 0

#7 Orjan

Orjan

    CC Mentor

  • Moderator
  • 2918 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#

Posted 30 September 2012 - 08:47 AM

This topic has been marked as SOLVED. If you have a similar question or topic, you can go back to the subforum and start a new topic to continue discussions.
  • 0

I'm a System developer at XLENT Consultant Group mainly working with SugarCRM.
Please DO NOT send mail or PM to me with programming questions, post them in the appropriate forum instead, where I and others can answer you.


#8 Luthfi

Luthfi

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1320 posts
  • Programming Language:PHP, Delphi/Object Pascal, Pascal, Transact-SQL
  • Learning:C, Java, PHP

Posted 30 September 2012 - 09:38 AM

When I replied the thread weren't marked as solved, and also the real solution had not been posted. So I added my solution/answer for the benefit of future reader. Is that wrong?
  • 0

#9 Orjan

Orjan

    CC Mentor

  • Moderator
  • 2918 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#

Posted 30 September 2012 - 09:50 AM

nope, its perfect!
  • 0

I'm a System developer at XLENT Consultant Group mainly working with SugarCRM.
Please DO NOT send mail or PM to me with programming questions, post them in the appropriate forum instead, where I and others can answer you.





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download