Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pause / Sleep 1

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Is it possible to make a pause (something like "sleep" in unix) in a cobol program for a specified time?

Thanx!
 
Yes.

What COBOL compiler are you using on what Unix?
Tom Morrison
 
This code works fine for OS/2, Windows and Unix:

SPECIAL-NAMES.
Call-convention 3 is OS2api,
Call-convention 74 is WINapi.

03 SleepMiliSec Pic 9(8) comp-5.
03 NanoSleep.
05 NanoSleepS pic 9(8) comp-5.
05 NanoSleepN pic 9(8) comp-5.
*
03 WS-Seconden pic 9(2)v9(3).
03 filler redefines
WS-Seconden.
05 WS-WholeSeconds pic 9(2).
05 WS-MiliS-remain pic 9(3).
03 filler redefines
WS-Seconden.
05 WS-MiliSeconds pic 9(5).
03 CBLrc pic 9(2) comp-x.


Evaluate true
when C8-OS2-16bit
Move WS-MiliSeconden to SleepMiliSec
Call "__DosSleep" using by value SleepMiliSec
End-call
when C8-OS2-32bit
Move WS-miliSeconds to SleepMiliSec
Call OS2api "DosSleep" using by value SleepMiliSec
returning CBLRc
End-call
when C8-Win-32bit
Move WS-MilioSeconds to SleepMiliSec
Call WINapi "Sleep" using by value SleepMiliSec
returning CBLRc
End-call
when C8-unix32Bit
Move WS-WholeSeconds to NanoSleepS
Multiply WS-MiliS-remain by 1000000 giving NanoSleepN
Call "nanosleep" using NanoSleep
returning CBLRc
End-call
end-evaluate.


 
've been playing with linux/OPENcobol. Challenged the sleep/pause issue. I won :) with this code:
Code:
$ cat ffpitte.cbl
       identification   division.
       program-id.      ffpitte.
       environment      division.
       configuration    section.
       input-output     section.
       file-control.
       data division.
       file section.
       working-storage section.
       77  uSleepMicroSec  pic 9(9) comp-5.
       procedure        division.
       0000-main        section.
       0000-010.
           perform varying       uSleepMicroSec from 1    by 00010000
                     until       uSleepMicroSec greater than 10000000
               display           uSleepMicroSec
               call "usleep"
                  using by value uSleepMicroSec
               end-call
           end-perform.
       0000-090.
           exit.
Yeah, this topic is more than 2 year old. Who cares?
 
Some flavor of Cobol for unix have the "system" call available.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top