You can call a program with a library qualification by using bindable APIs with library qualification.
Example:
The program T2123API uses DSM ILE bindable API calls to create a window and echo whatever is entered. The System API Reference contains information on the ILE bindable APIs. The prototypes for the DSM APIs are in the <qsnsess.h> header file. The extern "OS nowiden" return type API(arg_list); is specified for each API where return type is void or whatever type is returned by the API, and arg_list is the list of parameters taken by the API. This ensures any value argument is passed by value indirectly.
// This program uses Dynamic Screen Manager API calls to // create a window and echo whatever is entered. This is an // example of bound API calls. Note the use of extern linkage // in the <qsnsess.h> header file. OS, nowiden ensures that a // pointer to an unwidened copy of the argument is passed to the // API. // Use BNDDIR(QSNAPI) on the CRTPGM command to build this // example. #include <stddef.h> #include <string.h> #include <iostream.h> #include <qsnapi.h> #define BOTLINE " Echo lines until: PF3 - exit" // DSM Session Descriptor Structure. typedef struct{ Qsn_Ssn_Desc_T sess_desc; char buffer[300]; }storage_t; void F3Exit(const Qsn_Ssn_T *Ssn, const Qsn_Inp_Buf_T *Buf, char *action) { *action = '1'; } int main(void) { int i; storage_t storage; // Declarators for declaring windows. Types are from the <qsnsess.h> // header file. Qsn_Inp_Buf_T input_buffer = 0; Q_Bin4 input_buffer_size = 50; char char_buffer[100]; Q_Bin4 char_buffer_size; Qsn_Ssn_T session1; Qsn_Ssn_Desc_T *sess_desc = (Qsn_Ssn_Desc_T *) &storage; Qsn_Win_Desc_T win_desc; Q_Bin4 win_desc_length = sizeof(Qsn_Win_Desc_T); char *botline = BOTLINE; Q_Bin4 botline_len = sizeof(BOTLINE) - 1; Q_Bin4 sess_desc_length = sizeof(Qsn_Ssn_Desc_T) + botline_len; Q_Bin4 bytes_read; // Initialize Session Descriptor DSM API. QsnInzSsnD( sess_desc, sess_desc_length, NULL); // Initialize Window Descriptor DSM API. QsnInzWinD( &win_desc, win_desc_length, NULL); sess_desc->cmd_key_desc_line_1_offset = sizeof(Qsn_Ssn_Desc_T); sess_desc->cmd_key_desc_line_1_len = botline_len; memcpy( storage.buffer, botline, botline_len ); sess_desc->cmd_key_desc_line_2_offset = sizeof(Qsn_Ssn_Desc_T) + botline_len; // Set up the session type. sess_desc->EBCDIC_dsp_cc = '1'; sess_desc->scl_line_dsp = '1'; sess_desc->num_input_line_rows = 1; sess_desc->wrap = '1'; // Set up the window size. win_desc.top_row = 3; win_desc.left_col = 3; win_desc.num_rows = 13; win_desc.num_cols = 45; // Create a window session. sess_desc->cmd_key_action[2] = F3Exit; session1 = QsnCrtSsn( sess_desc, sess_desc_length, NULL, 0, '1', &win_desc, win_desc_length, NULL, 0, NULL, NULL); if(input_buffer == 0) { input_buffer = QsnCrtInpBuf(100, 50, 0, NULL, NULL); } for (;;) { // Echo lines until F3 is pressed. QsnReadSsnDta(session1, input_buffer, NULL, NULL); if (QsnRtvReadAID(input_buffer, NULL, NULL) == QSN_F3) { break; } } }
The output is:
+--------------------------------------------------------------------------------+ | iSeries Programming Develoment Manager (PDM) | | ................................................. | | : > abc : | | : > def : | | : : | | : : | | : : | | : : | | : : | | : : | | : : | | : : | | : ===> : | | : Echo lines until: PF3 - exit : | | : : | | :...............................................: | |Selection or command | |===> call pgm(mylib/t2123api) | |F3=Exit F4=Prompt F9=Retreive F10=Command entry | |F12=Cancel F18=Change Defaults | +--------------------------------------------------------------------------------+
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.