Anybody know any quit/reset commands?

Right now I'm still improvising with a repeat command to repeat the whole program and exit it by a simple write-readln command, it would look something like this:
[size=4]
Uses crt;
Var x: byte;
Begin
Repeat
Clrscr;
Writeln('hello world!');
Write('AGAIN?? (enter 1 to do it, 0 to exit)');
Until(x=0)
End.
[/size]
I want to somehow remove the ugly phrase "enter 1...", like letting the user press "esc" to exit or maybe an exit button and that I click with my mouse (I saw games written with pascal, some were really awesome, and they featured an exit button :P)

Comments

  • quikcarlxquikcarlx Hollywood, Fl
    As per the Free Pascal Compiler 2.6.0, you can use the [color=Purple][b]Exit[/b][/color] procedure in either a subroutine and in the main program. Below is a possible way to do the input character.
    [code] const
    esc = #27;

    var
    ec : char; {Entry Character }
    .
    .
    .
    ec := readkey;
    case ec of
    esc : begin
    { do something }
    end;
    'y','1' : begin
    { do something else }
    end;
    end;
    [/code]
  • : As per the Free Pascal Compiler 2.6.0, you can use the
    : [color=Purple][b]Exit[/b][/color] procedure in either a subroutine
    : and in the main program. Below is a possible way to do the input
    : character.
    : [code]: const
    : esc = #27;
    :
    : var
    : ec : char; {Entry Character }
    : .
    : .
    : .
    : ec := readkey;
    : case ec of
    : esc : begin
    : { do something }
    : end;
    : 'y','1' : begin
    : { do something else }
    : end;
    : end;
    : [/code]:
    :

    This all seems a bit confusing to me, how many variables will I need for this procedure? What is the difference between
    [code]const esc = 27[/code]
    And [code]const esc = #27[/code]
    What does the # do? Does it indicate a key on the keyboard when used in a const? Also, you wrote
    [code]var ec : char;
    ...
    Ec:= readkey;
    Case ec of
    Esc:begin ... End; [/code]
    So I suppose the esc const have something to do with the keyboard then?

    And I've never used the command 'case' before, is it similar to the if then command? If so then what's the difference?

    I don't understand what this part do:
    [code]'y', '1'
    ...
    ...
    {do something else}
    End; [/code]
    Would you explain everything to me a bit further? I'm still a highshcool student so my knowledge in pascal is very limited please be gentle with me :)
  • Nevermind this one...
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories