well first of all to all of those who have read all of my other stuff today thanks alot. I have tons of questions so i apreatiate the help. I was wondering if there is anyway to make a timer. I would configure a delay thing if i knew how to multi-task if that is even possible with pascal? so if you know of a built in timer,how to make one, or how to multitask i would apreacaite you telling me
thanks
wizarbo
Comments
: thanks
: wizarbo
:
Multitasking (true taskswitching in this case) requires much more than just implementing some timer. You also need to transfer memory and instructions at those times, and you need to do it very fast. I don't think turbo pascal (I'm note very familiar with freepascal to determine it) is able to handle these things.
What you could do is write an event-driven program. This is not multitasking as such, but it allows your program to perform background operations, while maintaining user-interface. I can help you with that if you like.
: well first of all to all of those who have read all of my other stuff today thanks alot. I have tons of questions so i apreatiate the help. I was wondering if there is anyway to make a timer. I would configure a delay thing if i knew how to multi-task if that is even possible with pascal? so if you know of a built in timer,how to make one, or how to multitask i would apreacaite you telling me
: thanks
: wizarbo
The best way to do a very acurate timer is to use the computer clock cycle timer. It increments 18.2/sec so it is pretty good for most things you want. You can also use Interrupts to set a timer with your own intervals (60/sec or whatever). I don't use these much, so I would have to do a lot of searching to find the answers you need. The best thing to do is to get a program called HELPPC by David Jurgens. It has information on assembly, timers, C++, Joystick Ports, Mouse ports, interrupts and pretty much everything else. Awesome document. I'm not sure if it mentions the Computer clock cycle counter, but that is found in memory (somewhere near Mem[$0000:$0100] I think) You could write a loop to display 2000 bytes of memory from Mem[$0000:$0100+Counter] on the screen repeatedly and look for the bytes that are changing. This is usually how I find it. anyways, simply put, get HELPPC.
Phat Nat
Actually just found this in HelpPC (took about 5 seconds, hehe):
[code]
HelpPC 2.10 Quick Reference Utility Copyright 1991 David Jurgens
INT 1A,0 - Read System Clock Counter
AH = 00
on return:
AL = midnight flag, 1 if 24 hours passed since reset
CX = high order word of tick count
DX = low order word of tick count
- incremented approximately 18.206 times per second
- at midnight CX:DX is zero
- this function can be called in a program to assure the date is
updated after midnight; this will avoid the passing two midnights
date problem
Esc or Alt-X to exit int 1a,0
[/code]
: : thanks
: : wizarbo
: :
: Multitasking (true taskswitching in this case) requires much more than just implementing some timer. You also need to transfer memory and instructions at those times, and you need to do it very fast. I don't think turbo pascal (I'm note very familiar with freepascal to determine it) is able to handle these things.
: What you could do is write an event-driven program. This is not multitasking as such, but it allows your program to perform background operations, while maintaining user-interface. I can help you with that if you like.
:
That would be great!!!I would have no clue how to do that. Where did you learn all of this stuff cuse if you red something Please tell me what it is so that i could read it and not bug you all the time. And thanks for all the help!!!!!!!!!!!!!!!
: : : thanks
: : : wizarbo
: : :
: : Multitasking (true taskswitching in this case) requires much more than just implementing some timer. You also need to transfer memory and instructions at those times, and you need to do it very fast. I don't think turbo pascal (I'm note very familiar with freepascal to determine it) is able to handle these things.
: : What you could do is write an event-driven program. This is not multitasking as such, but it allows your program to perform background operations, while maintaining user-interface. I can help you with that if you like.
: :
: That would be great!!!I would have no clue how to do that. Where did you learn all of this stuff cuse if you red something Please tell me what it is so that i could read it and not bug you all the time. And thanks for all the help!!!!!!!!!!!!!!!
:
I taught myself it by looking at the source codes of TurboVision. Event driven programming isn't that difficult. Here is a simple example program to illustrate it.
[code]
uses
Crt;
var
Event: integer;
Text : string;
procedure HandleKeyBoardEvents;
var
ch: char;
begin
ch := readkey;
if upcase(ch) = 'Q' then { if user presses Q then }
Event := 1 { end program }
else begin { else }
Text := Text + ch; { add key to the text }
GotoXY(1,1); write(Text); { and display it }
end;
end;
procedure HandleOtherEvents;
var
Sec, sec100, min, hour: word;
begin
GetTime(Hour, min, sec, sec100);
if sec mod 100 = 0 then { if on the second }
GotoXY(1,4); write(Hour, ':', min, ':', sec); { show time }
end;
begin
clrscr;
repeat
Event := 0; { no event yet }
if KeyPressed then
HandleKeyBoardEvents;
HandleOtherEvents;
until Event = 1; { Event 1 = end program }
end.
[/code]
This program should work like a small text editor with a clock displayed a few lines lower. It is not much, but from a user perspective it looks like the program is doing 2 things at the same time: waiting for his input and maintaining a clock.
Here is a small addition for the HandleOtherEvents procedure:
[code]
if min mod 60 = 0 then begin
Sound(220);
Delay(100);
NoSound;
end;
[/code]
It should be obvious what happens. With a little extra programming you can event let the program chime the number of hours, while you are typing.