Simulate a key stroke using CL on an AS/400 system?

205 pts.
Tags:
AS/400
AS400 iseries
CL Commands
CL programming
Just currious, but is there a way to simulate a key stroke like the >enter< key within a cl prog on an as400 system?   

Thanks.



Software/Hardware used:
as400 iseries

Answer Wiki

Thanks. We'll let you know when a new response is added.

Yes, it can. But it’s unlikely that you will do it.

One general method would be through the use of the <a href=”http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=%2Fapis%2Fvt1a.htm”>Virtual Terminal APIs</a>. It shouldn’t take much reading about those to see why they aren’t intended for trivial tasks.

Another method could be to open a socket to the telnet server and process the socket data. You can read the screen data that comes across the socket and send back data bytes that stands for key strokes. Your program needs to recognize every type of screen that might come up, including error message screens and the messages, break message screens and all others. That’s not especially easier than the Virtual Terminal APIs.

The question doesn’t make total sense.

You can’t enter key strokes unless there is something to put the key strokes in to. Clearly, there must be some type of display file active that is waiting for input. The active display file will be the target of the key stroke.

But a display file is going to be waiting for a key stroke only if some program is already performing I/O through the display file. If that program is running, then your program won’t be running. That other program will have the device allocated. If your program isn’t running, then it can’t enter key strokes. If the display file is waiting for input, then the program behind it isn’t running — it’s in a wait state.

There are possible ways around all of that, but it gets complicated fast.

Your question needs to be asked differently.

You need to describe the <i>business problem</i> that you are trying to solve. A solution might be available that avoids complexities of key strokes.

Tom

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

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

Forgot Password

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

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

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

Thanks! We'll email you when relevant content is added and updated.

Following