|
|
![]() |
|
|
Display Operations Navigator from a 5250 Green Screen by Shannon O'Donnell [The code for this article is available for download.]
Running PC applications from an AS/400 has long been a fascination with me. I guess it's because the AS/400's character-based 5250 green screen is so boring and PCs are so dynamic and exciting. Whatever the reason, I'm always looking for new things I can do to better integrate the AS/400 with the PC. In this article, I'll show you how easy it is to display the Operations Navigator GUI from within your 5250 green screen application. Visual Basic to the Rescue I've been using Microsoft Visual Basic a lot lately, and I have to tell you it's a pretty darn good tool! If you've spent days and days simply trying to get a Java application to compile (because the Java tool you are using cannot even find the compiler--ahh, the joy of having to manually set Windows environment variables), you'll really appreciate the ease of using Visual Basic. With VB, you simply install the tool, and you are ready to rock and roll. There's no fiddling around with trying to get the IDE to load (like there frequently is with Java IDEs), and you don't have to have a honking big PC with giga-doodles of memory (like you do with Java development tools). However, since this isn't supposed to be a commercial for Microsoft Visual Basic, let me just end this by saying that VB is extremely easy to use and you can very rapidly build professional quality applications with a minimal learning curve. The Visual Basic Pieces For this article, I used Visual Basic and a couple of AS/400 Client Access ActiveX objects (both are contained in the OCX file named unoxctl.ocx and automatically installed and registered on your PC when you install Client Access Express) to display the Operations Navigator tree. In fact, I recently wrote about these two ActiveX objects in "The Client Access Express Toolkit," where I showed you how easy it is to display an Operations Navigator view from a Web page. In this example, I've added the two ActiveX controls, AS400Tree and AS400List, to a Visual Basic form. In addition, on this form, I've added a Microsoft Winsock control. The Winsock control allows your VB application to communicate with other applications, regardless of what language they were written in, via a TCP/IP socket. I am not going to cover the concept of sockets in too much detail here. Suffice it to say that any activity on the Internet that requires a dedicated connection, such as FTP or even PC5250 emulation, communicates between a host and a client via a socket. The VB code for this tool, opsnavvb1, is really simple. You can see there isn't a whole lot to it. When you're creating this on your own, follow these steps:
The only other thing you'll probably want to change is the WindowsState property, which can be found on the properties panel for the form itself. Set this property to Minimized. That way, when you start the application, it'll run in a minimized, or hidden, state until you want it to display. Compile your application and make an executable file from it. If you're not sure how to create an executable, click the File menu option, then the submenu item Make exe. The AS/400 Side of the House On the AS/400 side of the house, you'll need at least one 5250 display file and one RPG IV program capable of sending a data request via a socket to the PC. The display file in our example, opsnavd1, is pretty simple. It shows a blank screen with two command key indicators. Pressing F3 will end the program. Pressing F5 will execute the RPG IV routines (opsnavr1) to communicate with the PC program via a socket connection. Since we're not actually sending data to the PC for this example, all we really need to do is send an empty buffer to the socket and let it communicate with the PC application via the specified port (4050, in this example). The code I'm using for the socket connection is from an RPG IV program has been around for quite a while now. I first wrote about it and explained how to use it in the pages of Midrange Computing magazine several years ago, and I'll likely cover this topic again in Midrange Programmer in the near future. Putting It All Together So those are the pieces. It's a pretty simple matter, then, to tie it all together. On the PC side, add a shortcut to the VB program you just created to the Windows Startup folder. You can use Windows Explorer to drag the executable file to the Startup folder. That way, every time Windows starts, the VB application will also start. And since it's running in a minimized state, it'll just be running unobtrusively in the background on the user's PC. On the AS/400, compile the 5250 application, then call it from the PC that has the VB program running on it. If you're connected via TCP/IP, when you press F5 from the 5250 application, you should see the VB application display, showing you the Operations Navigator tree. When you click the Hide Ops Nav Panel button, the OpsNav display will be hidden and you will be returned to the 5250 display.
|
Editors
Contact the Editors |
|
Last Updated: 11/7/02 Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved. |