Highlighted
Absent Member.
Absent Member.
943 views

How to put a program to sleep

Jump to solution

The environment is Visual COBOL 2017 and the objective is to put a program into sleep mode for one minute. Looking in the COBOL manual there is a System Routine of CBL GC NANOSLEEP that will do the job but the call to this routine fails (not found). Searching my C drive does not find the routine. So my questions are;

1. Is this routine the way to go or are there other alternatives? 

2.  If this is the alternative, how do I acquire this System Routine?

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: How to put a program to sleep

Jump to solution

I believe that you are looking in the manual for the GnuCOBOL product and not for Micro Focus Visual COBOL.

There is a routine in Visual COBOL called CBL_THREAD_SLEEP that can be used.

It is documented here:

Example:

 

       01 any-key  pic x.
       01 sleep-time  pic x(4) comp-5 value 60000.
       procedure division.
           display "this is a test of sleep for one minute"
           call "CBL_THREAD_SLEEP" using sleep-time
           display "after sleep"
           accept any-key
           goback.

View solution in original post

0 Likes
3 Replies
Highlighted
Absent Member.
Absent Member.

RE: How to put a program to sleep

Jump to solution
How about a straight win api call for native COBOL -you didn't mention if you're doing COBOL.NET or native.

special-names.
call-convention 74 IS Winapi.


01 sleep-milliseconds pic x(4) comp-5.

move 60000 to sleep-milliseconds.
call WinApi 'Sleep' using by value sleep-milliseconds.

Neil
0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: How to put a program to sleep

Jump to solution

I believe that you are looking in the manual for the GnuCOBOL product and not for Micro Focus Visual COBOL.

There is a routine in Visual COBOL called CBL_THREAD_SLEEP that can be used.

It is documented here:

Example:

 

       01 any-key  pic x.
       01 sleep-time  pic x(4) comp-5 value 60000.
       procedure division.
           display "this is a test of sleep for one minute"
           call "CBL_THREAD_SLEEP" using sleep-time
           display "after sleep"
           accept any-key
           goback.

View solution in original post

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: How to put a program to sleep

Jump to solution
Thanks, worked like a champ. And thanks for note about proper COBOL Manual
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.