Q

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

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.

0 comments

Oldest 

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:

-ADS BY GOOGLE

SearchEnterpriseLinux

SearchDataCenter

Close