Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4106
Number of posts: 14016

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
working clock Posted by ricketts on 22 Sept 2003 at 3:09 AM
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
Report
Re: working clock Posted by zibadian on 22 Sept 2003 at 5:41 AM
: 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).
Report
Re: working clock Posted by Phat Nat on 9 Oct 2003 at 7:08 PM
: 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:
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.





 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.