Problem solve Get help with specific problems with your technologies, process and projects.

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 


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 last published in October 2001

Dig Deeper on RPG iSeries programming

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

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

Please create a username to comment.