Howdy, Stranger!

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

Categories

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.

working clock

rickettsricketts Posts: 1Member
is there a way in which you can get the system clock to work in your program but still have your program run normally. i mean can the clock go up second by second during the running of the program

Comments

  • zibadianzibadian Posts: 6,349Member
    : is there a way in which you can get the system clock to work in your program but still have your program run normally. i mean can the clock go up second by second during the running of the program
    :
    The best way to do this is to use interrupts, but that is quite difficult to program. The second best way is to write your program event-driven. This is quite a lot of work, with small more challenging programming problems, but it is do-able.
    If you're using TP 6 or 7, you might consider learning Turbo Vision programming. Then you don't have to reinvent the wheel (=event-driven programming).
  • Phat NatPhat Nat Posts: 757Member
    : is there a way in which you can get the system clock to work in your program but still have your program run normally. i mean can the clock go up second by second during the running of the program
    :

    Use Interrupts. They aren't that difficult to use. Just remember that you can't do too much in an interrupt because they get called often (ex. the timer routine gets called 18.2/sec)

    Here's a TP7 example:
    [code]
    UNIT Clock;

    INTERFACE

    IMPLEMENTATION

    USES Dos;

    VAR OldTimerInt : Pointer;
    OldExit : Pointer;

    { New timer interrupt }
    PROCEDURE TimerInt; interrupt;
    Begin
    CallInt(OldTimerInt);
    (*** Your Code Here (remember to keep it short) ***)
    End;

    { Reset old timer }
    PROCEDURE SetOldTimInt;
    Begin
    ExitProc := OldExit;
    SetIntVec($1C, OldTimerInt);
    STI;
    End;

    Begin
    OldExit := ExitProc;
    ExitProc := @SetOldTimInt; { On Exit, Autmatically restore Int }
    GetIntVec($1C, OldTimerInt); { Record location of old Interrupt }
    SetIntVec($1C, @TimerInt); { Install new interrupt procedure }
    End.
    [/code]

Sign In or Register to comment.