Procedure Delay in TPW 
Author Message
 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.


Wed, 18 Jun 1902 08:00:00 GMT  
 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.

use sleep();

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

Author of the free Chatsystem PINO!
Available at http://www.*-*-*.com/



Wed, 18 Jun 1902 08:00:00 GMT  
 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.

> use sleep();

Tried that, and it said "Unknown identifier".


Wed, 18 Jun 1902 08:00:00 GMT  
 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.

> > 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.*-*-*.com/ {*filter*}bath.com/  **

Author of the free Chatsystem PINO!
Available at http://www.*-*-*.com/



Wed, 18 Jun 1902 08:00:00 GMT  
 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.

> > 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



Wed, 18 Jun 1902 08:00:00 GMT  
 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.*-*-*.com/ {*filter*}bath.com/  **

Author of the free Chatsystem PINO!
Available at http://www.*-*-*.com/



Wed, 18 Jun 1902 08:00:00 GMT  
 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.

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



Wed, 18 Jun 1902 08:00:00 GMT  
 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



Wed, 18 Jun 1902 08:00:00 GMT  
 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.

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://www.geocities.com/~franzglaser/ http://members.xoom.com/f_glaser/


Wed, 18 Jun 1902 08:00:00 GMT  
 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.

Use a loop.

Quote:

>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)

--

"Warning: Witty signature file not found."



Wed, 18 Jun 1902 08:00:00 GMT  
 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.

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



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. TPW 1.5 (Delays)

2. delay in tpw

3. delay procedure & time of cpu (BP7)

4. Delay procedure

5. Own delay procedure

6. Problem with Delay procedure on 486s

7. Database procedures for TPW/TP6.0???

8. Type Procedure Pascal(TPW)

9. TPW: How to print TPW prog output ?

10. TPW: How to print TPW prog output ?

11. Calling a procedure within a procedure

12. HELP - calling a Procedure from with a Procedure??

 

 
Powered by phpBB® Forum Software