Ask the Expert

Writing a clock program

I want to write a clock program that will show the time on the screen, but the time should change without any user's input (such as pressing ENTER key). I wrote one program, but that changes time only when I press ENTER or any function key. The program flow stops at EXFMT statement. I tried to use WRITE statement in a loop instead of EXFMT, but then the screen gets locked without changing the time.


You need to use a combination of WRITE [the record format] and READ [the file] instead of EXFMT. On top of this, you also need to create (or change or possibly override) your display file with WAITRCD (the number of seconds allowed to press a key). The RPG program should declare as keyword for the display file:

 F a_file   cf   e             workstn maxdev(*file) 

Please note, you will get a I/O error on the read if the user does not press a key in the time allotted, so you need to have a I/O indicator on the read (or use the (E) extension). Good idea to do the same on the write.

 Example follows:

C                   write (e) a_format
C                   read  (e) a_file 

==================================
MORE INFORMATION ON THIS TOPIC
==================================

The Best Web Links: tips, tutorials and more.

Ask your systems management questions--or help out your peers by answering them--in our live discussion forums.


This was first published in October 2001

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: