Changing the Default Program Device IBM-ILE

You can change the default device for a device file.

Example

The following example illustrates how to change the default program device using the _Rpgmdev() function.

Note: To run this example you must use two display devices that are defined on your system in place of DEVICE1 and DEVICE2.

  1. To create the display file T1520DDE using the DDS shown below, type:
  2. CRTDSPF FILE(MYLIB/T1520DDE) SRCFILE(QCLE/QADDSSRC) MAXDEV(2)

    T1520DDE — DDS Source for Name and Password Display

     DDS Source for Name and Password Display

  3. To override the file STDOUT with the printer file QPRINT,type:
  4. OVRPRTF FILE(STDOUT) TOFILE(QPRINT)
  5. To create the program T1520CDV using the source shown below, type:
  6. CRTBNDC PGM(MYLIB/T1520CDV) SRCFILE(QCLE/QACSRC)

    T1520CDV — ILE C Source to Change the Default Device

     ILE C Source to Change the Default Device

     ILE C Source to Change the Default Device

     ILE C Source to Change the Default Device

    The ILE C program T1520CDV uses the _Racquire() function to explicitly acquire another device that is named DEVICE1. DEVICE1 becomes the current program device.The _Rpgmdev() function changes the current device that is named DEVICE1 to DEVICE2. The _Rreadindv() function reads records from DEVICE1. The _Release() function releases DEVICE1 and DEVICE2.

  7. To run the program T1520CDV, type:
  8. CALL PGM(MYLIB/T1520CDV)

    The output is as follows:

    output

    When the application is run, a different display appears on each device. Data may be entered on both displays, but the data that is first entered is returned to the program. The output from the program is in QPRINT. For example, if the name SMITH and the address 10 MAIN ST is entered on DEVICE1 before any data is entered on DEVICE2, then the file QPRINT contains:

    Data displayed on DEVICE1 is SMITH 10 MAIN ST

    Note: There are two record formats that are created in the above example. One has a size of 45 characters (fmt1), and the other a size of 18 characters (fmt2). The union buf contains two record format declarations.


Face Book Twitter Google Plus Instagram Youtube Linkedin Myspace Pinterest Soundcloud Wikipedia

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

IBM-ILE Topics