Howdy, Stranger!

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

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

setting a speed in Pascal

sirisssiriss Posts: 4Member
Hi, all.
I'd like to know how I can set the speed of the steps followed by a program in Pascal. I'm doing a program that deletes the letters of a sentence, from the end of that sentence to the beggining, and it has to be one letter per second.

waiting for suggestions,

siriss.

Comments

  • Actor21Actor21 Posts: 35Member
    The CRT unit has a procedure called [b]delay[/b].
    [code]
    program howto ;

    uses crt ;

    begin
    delay(1000)
    end
    [/code]
    The argument of [b]delay[/b] is the length of the delay in milliseconds. [b]delay(1000)[/b] pauses the program for one second. Depending on how accurate your delay has to be you might want to use [b]delay(950)[/b] or some other number less than 1000. Experiment.
  • sirisssiriss Posts: 4Member
    Well, stil not working..

    Program del_sentence;
    var s: string;
    i: byte;
    uses crt;
    begin
    clrscr;
    writeln('sentence is deleting itself');
    readln(s);
    for i:=length(s) downto 2 do begin
    s[i]:=' ';
    delay(1000);
    end;
    end.

    What .. did I miss? Everything seemed fine to me.,
    Thanks again.
  • sirisssiriss Posts: 4Member
    Well, stil not working..

    Program del_sentence;
    var s: string;
    i: byte;
    uses crt;
    begin
    clrscr;
    writeln('sentence is deleting itself');
    readln(s);
    for i:=length(s) downto 2 do begin
    s[i]:=' ';
    delay(1000);
    end;
    end.

    What .. did I miss? Everything seemed fine to me.,
    Thanks again.
  • sirisssiriss Posts: 4Member
    Well, stil not working..

    Program del_sentence;
    var s: string;
    i: byte;
    uses crt;
    begin
    clrscr;
    writeln('sentence is deleting itself');
    readln(s);
    for i:=length(s) downto 2 do begin
    s[i]:=' ';
    delay(1000);
    end;
    end.

    What .. did I miss? Everything seemed fine to me.,
    Thanks again.
  • Actor21Actor21 Posts: 35Member
    [code]
    program del_sentence ;

    uses crt ; {[red] 'uses' must be first statement after 'program' [/red] }

    var
    s : string ;
    i : byte ;

    begin
    clrscr ;
    write ('Enter a sentence. ') ;
    readln(s) ;
    writeln('sentence is deleting itself') ;

    while length(s) > 0 do begin
    writeln(s) ;
    delete(s,length(s),1) ; {[red] use 'delete' - not s[1] = '' [/red]}
    delay (1000) {[red] 'delay' does not seem to work on my machine
    I had to use 15000 for a one second delay
    experiment [/red]}
    end
    end.
    [/code]
Sign In or Register to comment.