Board index » delphi » Procedure Delay in TPW

Procedure Delay in TPW

Looks like there isn't a "Delay" procedure in Turbo Pascal for Windows 1.5. Is
there a substitution for it? Thank you.
 

Re:Procedure Delay in TPW


Quote
simboy wrote:

> Looks like there isn't a "Delay" procedure in Turbo Pascal for Windows 1.5. Is
> there a substitution for it? Thank you.

use sleep();

Alex
--
** Pepsi Cola and Animal protection **
**  http://www.pepsi{*word*76}bath.com/  **

Author of the free Chatsystem PINO!
Available at http://pino.cjb.net

Re:Procedure Delay in TPW


Quote
Alexander Mueller wrote:

> simboy wrote:

> > Looks like there isn't a "Delay" procedure in Turbo Pascal for Windows 1.5. Is
> > there a substitution for it? Thank you.

> use sleep();

Tried that, and it said "Unknown identifier".

Re:Procedure Delay in TPW


Quote
simboy wrote:

> Alexander Mueller wrote:

> > simboy wrote:

> > > Looks like there isn't a "Delay" procedure in Turbo Pascal for Windows 1.5. Is
> > > there a substitution for it? Thank you.

> > use sleep();

> Tried that, and it said "Unknown identifier".

Well I am not using TPW but I suppose you have forgotten to include the
unit needed for sleep. In Delphi it would be windows.pas but I dont know
which in TPW.

Alex
--
** Pepsi Cola and Animal protection **
**  http://www.pepsi{*word*76}bath.com/  **

Author of the free Chatsystem PINO!
Available at http://pino.cjb.net

Re:Procedure Delay in TPW


Quote
simboy wrote:

> Alexander Mueller wrote:

> > simboy wrote:

> > > Looks like there isn't a "Delay" procedure in Turbo Pascal for Windows 1.5. Is
> > > there a substitution for it? Thank you.

> > use sleep();

> Tried that, and it said "Unknown identifier".

It is a Delphi procedure AFAIK.

Look in the FAQ page of the TP - links, especially for Dr. John
Stockton's timing page. Another address is in the serial chapter,
AuxUnit example has a procedure for the delay. It was from one
of the EXAMPLES which were part of the BP 7 package. I think that
this should be part of TPW 1.x too.

http://bsn.ch/tp-links

:-)
--
Franz Glaser, Glasau 3, A-4191 Vorderweissenbach Austria +43-7219-7035-0
Muehlviertler Elektronik Glaser.  Industrial control and instrumentation
http://members.eunet.at/meg-glaser/    http://members.xoom.com/f_glaser/
http://www.geocities.com/~franzglaser/            http://start.at/bedarf

Re:Procedure Delay in TPW


No sleep is a normal WIN32 (WIN16?) procedure (oops sorry void function
:))). You can find it in your Windows SDK help.

Alex
--
** Pepsi Cola and Animal protection **
**  http://www.pepsi{*word*76}bath.com/  **

Author of the free Chatsystem PINO!
Available at http://pino.cjb.net

Re:Procedure Delay in TPW


Quote
simboy wrote in message <382F27A0.32304...@anonymous.com>...
>Looks like there isn't a "Delay" procedure in Turbo Pascal for
Windows 1.5. Is
>there a substitution for it? Thank you.

Under win16 (which is the platform of TPW15) there is no place for a
'delay' procedure. The win16 platform is not a pre-emptive o/s - it is
a co-operative multitasking o/s. So, no application can 'hog' the
processor for more time than is neccessary. It should yield (via the
getmessage/translatemessage loop) as soon as possible after handling a
message.

    To implement a 'delay' under win16, use the settimer/WM_TIMER
paradigm. Windows will send the WM_TIMER message to your app after the
time period set by the settimer procedure has 'timed out'. In the
meanwhile, windows will have been able to give processor time to other
apps/windows.

p.s. the above analysis is not applicable to 32-bit apps under win32
(W95/98) - they are pre-emptive o/s.
--
Jeremy O'Connor
line 2
line 3
line 4

Re:Procedure Delay in TPW


Quote
>Looks like there isn't a "Delay" procedure in Turbo Pascal for Windows 1.5.
>Is
>there a substitution for it? Thank you.

The GetTickCount function from the WinProcs unit returns the number of
milliseconds that have elapsed since Windows was started. Using it you can
create a little loop and create your own delay function.

James

Re:Procedure Delay in TPW


Quote
JKe7306087 wrote:

> >Looks like there isn't a "Delay" procedure in Turbo Pascal for Windows 1.5.
> >Is
> >there a substitution for it? Thank you.

> The GetTickCount function from the WinProcs unit returns the number of
> milliseconds that have elapsed since Windows was started. Using it you can
> create a little loop and create your own delay function.

This is not an excellent idea. It does waste time in a dead loop
that could be used by another multi-task meanwhile.
:-)
--
Franz Glaser, Glasau 3, A-4191 Vorderweissenbach Austria +43-7219-7035-0
Muehlviertler Elektronik Glaser.  Industrial control and instrumentation
http://members.eunet.at/meg-glaser/           mailto:meg-gla...@eunet.at
http://www.geocities.com/~franzglaser/ http://members.xoom.com/f_glaser/

Re:Procedure Delay in TPW


Quote
simboy wrote:
> Looks like there isn't a "Delay" procedure in Turbo Pascal for Windows 1.5. Is
> there a substitution for it? Thank you.

Use a loop.

Quote
Ing. Franz Glaser wrote:
>This is not an excellent idea. It does waste time in a dead loop
>that could be used by another multi-task meanwhile.

True, but how to do it any other way? Timers are scarce.

Here is the code I use in most of my work:

Var dtM:tMsg;   {declared outside, reason forgotten}
Var dtL:Longint;
Procedure Delay(Time:Longint);
Begin
  dtL:=GetTickCount+Time;
  Repeat
        While PeekMessage(dtM,0,0,0,pm_Remove) Do
        Begin
             TranslateMessage(dtM);
             DispatchMessage(dtM);
        End;
  Until GetTickCount>=dtL;
End;

Ideas:
1. Leave out the TranslateMessage(dtM)) if you are using this only for
VERY short delays.
2. Change the Time:Longint to Time:word if you need to. {Can't think of
reason why}
3. Change PeekMessage to GetMessage if you know your app WILL be getting
messages constantly.

Can anyone add any improvements? I would be thankful. (-?l)

--
http://www.geocities.com/aibrain/   -Email: aibr...@usa.net

"Warning: Witty signature file not found."

Re:Procedure Delay in TPW


Quote
simboy (anonym...@anonymous.com) wrote:

: Looks like there isn't a "Delay" procedure in Turbo Pascal for Windows 1.5. Is
: there a substitution for it? Thank you.

In the german version of Borland Pascal 7
the demo for the delay procedure contains
this code for Windoze:

Procedure Delay(ms : LongInt);
Var
  TickCount : LongInt;
  M         : TMsg;
Begin
  TickCount := GetTickCount;
  While GetTickCount - TickCount < ms do
    If PeekMessage(M,0,0,0,pm_Remove) then
      Begin
        TranslateMessage(M); DispatchMessage(M);
      End;
End;

--
Klaus Hartnegg, Institut fuer Biophysik, Hansa-Strasse 9a, D-79104 Freiburg
hartn...@uni-freiburg.de   http://www.brain.uni-freiburg.de/~klaus/

Other Threads