ibm-information-center/dist/eclipse/plugins/i5OS.ic.apis_5.4.0.1/dsm1g.htm

575 lines
23 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Copyright" content="Copyright (c) 2006 by IBM Corporation">
<title>Low-Level Services Examples</title>
<!-- Begin Header Records ========================================= -->
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<!-- Change History: -->
<!-- YYMMDD USERID Change description -->
<!-- DSMMST1 SCRIPT A converted by B2H R4.1 (346) (CMS) by V2KEA304 -->
<!-- at RCHVMW2 on 29 Jan 1999 at 16:05:09 -->
<!-- File Edited November 2001 -->
<!-- End Header Records -->
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
</head>
<body>
<!-- Java sync-link -->
<script language="Javascript" src ="../rzahg/synch.js" type="text/javascript"></script>
<h2>Low-Level Services Examples</h2>
<h3><a name="HDRLLEX1">Low-Level Services Example--1</a></h3>
<p>The sample ILE C program in Figure 1 shows how to use the Write Data
(QsnWrtDta), Get AID (QsnGetAID), and Roll Up (QsnRollUp) APIs. The program
writes a line at the bottom of the screen and if F3 is not pressed, rolls
the screen up and writes a new line at the bottom of the screen. The roll
area for the QsnRollUp API is defined to be from row 1 to 24 and one line
is rolled up. If F3 is pressed, the program ends. A partial screen display
is shown in <a href="#FIGLLEX1A">Figure 2</a>.</p>
<p><strong><a name="FIGLLEX1">Figure 1. Program to Roll Text on Screen</a></strong></p>
<table border>
<tr>
<td>
<pre>
#include &lt;stdlib.h&gt;
#include &lt;stdio.h&gt;
#include &lt;string.h&gt;
#include &quot;qsnapi.h&quot;
int main(void)
{
long i;
char s[100];
QsnClrScr('0', 0, 0, NULL);
for (i = 1; ; ++i) {
sprintf(s, &quot;Line %2.d. Press Enter to roll, F3 to quit.&quot;, i);
QsnWrtDta(s, strlen(s), 0, 24, 2, QSN_SA_NORM, QSN_SA_NORM,
QSN_SA_NORM, QSN_SA_NORM, 0, 0, NULL);
if (QsnGetAID(NULL, 0, NULL) == QSN_F3)
break;
QsnRollUp(1, 1, 24, 0, 0, NULL);
}
}
</pre>
</td>
</tr>
</table>
<br>
<br>
<p><strong><a name="FIGLLEX1A">Figure 2. Screen Output from Roll Text Program</a></strong></p>
<table border>
<tr>
<td>
<pre>
+--------------------------------------------------------------------------------+
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| Line 1. Press Enter to roll, F3 to quit. |
| Line 2. Press Enter to roll, F3 to quit. |
| Line 3. Press Enter to roll, F3 to quit. |
| Line 4. Press Enter to roll, F3 to quit. |
| Line 5. Press Enter to roll, F3 to quit. |
| Line 6. Press Enter to roll, F3 to quit. |
| Line 7. Press Enter to roll, F3 to quit. |
| Line 8. Press Enter to roll, F3 to quit. |
| |
+--------------------------------------------------------------------------------+
</pre>
</td>
</tr>
</table>
<br>
<br>
<h3><a name="HDRLLEX2">Low-Level Services Example--2</a></h3>
<p>Figure 3 shows how to use the Query 5250 (QsnQry5250) API. A sample display
is shown in <a href="#FIGLLEX2A">Figure 4</a>.</p>
<p><strong><a name="FIGLLEX2">Figure 3. Program Using the Query 5250 (QsnQry5250) API</a></strong></p>
<table border>
<tr>
<td>
<pre>
#include &lt;stdlib.h&gt;
#include &lt;stdio.h&gt;
#include &lt;string.h&gt;
#include &quot;qsnapi.h&quot;
#define TRUE 1
#define FALSE 0
int main(void)
{
Qsn_Qry_5250_T qry5250;
Qsn_WSC_display_T *dsp = (Qsn_WSC_display_T *)(qry5250.WSC_display);
char s[100];
Q_Bin4 row;
Qsn_Cmd_Buf_T buf;
QsnQry5250(&amp;qry5250, sizeof(qry5250), NULL);
buf = QsnCrtCmdBuf(100, 20, 0, NULL, NULL);
QsnClrScr('0', buf, Q_NO_HANDLE, NULL);
sprintf(s, &quot;Query status is %c, num input fields: %d, color: %c, wide: %c&quot;,
qry5250.query_status, qry5250.num_input_capable,
(QsnQryColorSup(NULL, Q_NO_HANDLE, NULL) == TRUE ? 'Y' : 'N'),
(dsp-&gt;scr_size == 3 ? 'Y' : 'N'));
QsnWrtDta(s, strlen(s), 0, row=5, 5, QSN_SA_NORM, QSN_SA_NORM,
QSN_SA_NORM, QSN_SA_NORM, buf, Q_NO_HANDLE, NULL);
sprintf(s, &quot;GUI display: %d, GUI support: %d&quot;,
dsp-&gt;GUI_display, dsp-&gt;GUI_support);
QsnWrtDta(s, strlen(s), 0, row+=2, 5, QSN_SA_NORM, QSN_SA_NORM,
QSN_SA_NORM, QSN_SA_NORM, buf, Q_NO_HANDLE, NULL);
sprintf(s, &quot;Move cursor: %d, Row1/Col1: %d, ReadMDTImmAlt: %d&quot;,
dsp-&gt;move_csr_order, dsp-&gt;row1_col1, dsp-&gt;Read_MDT_Imm_Alt);
QsnWrtDta(s, strlen(s), 0, row +=2, 5, QSN_SA_NORM, QSN_SA_NORM,
QSN_SA_NORM, QSN_SA_NORM, buf, Q_NO_HANDLE, NULL);
sprintf(s, &quot;Extended primary attributes: %d, DBCS: %x&quot;,
dsp-&gt;extended_pri_atr_DP, dsp-&gt;DBCS);
QsnWrtDta(s, strlen(s), 0, row +=2, 5, QSN_SA_NORM, QSN_SA_NORM,
QSN_SA_NORM, QSN_SA_NORM, buf, Q_NO_HANDLE, NULL);
sprintf(s, &quot;Wide mode on: %c&quot;,
QsnRtvMod(NULL, Q_NO_HANDLE, NULL) == QSN_DSP04 ? 'y' : 'n');
QsnWrtDta(s, strlen(s), 0, row +=2, 5, QSN_SA_NORM, QSN_SA_NORM,
QSN_SA_NORM, QSN_SA_NORM, buf, Q_NO_HANDLE, NULL);
sprintf(s, &quot;Wide mode allowed: %c&quot;,
QsnQryModSup(QSN_DSP04, NULL, Q_NO_HANDLE, NULL) ==
TRUE ? 'y' : 'n');
QsnWrtDta(s, strlen(s), 0, 13, 5, QSN_SA_NORM, QSN_SA_NORM,
QSN_SA_NORM, QSN_SA_NORM, buf, Q_NO_HANDLE, NULL);
QsnPutBuf(buf, Q_NO_HANDLE, NULL);
QsnGetAID(NULL, Q_NO_HANDLE, NULL);
}
</pre>
</td>
</tr>
</table>
<br>
<br>
<p><strong><a name="FIGLLEX2A">Figure 4. Screen Output from QsnQry5250 API Program</a></strong></p>
<table border>
<tr>
<td>
<pre>
+--------------------------------------------------------------------------------+
| |
| |
| |
| |
| Query status is 1, num input fields: 500, color: Y, wide: Y |
| |
| GUI display: 1, GUI support: 1 |
| |
| Move cursor: 0, Extended primary attributes: 0 |
| |
| Wide mode on: n |
| |
| Wide mode allowed: y |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
+--------------------------------------------------------------------------------+</pre>
</td>
</tr>
</table>
<br>
<br>
<h3><a name="HDRLLEX3">Low-Level Services Example--3</a></h3>
<p>The sample program in Figure 5 shows how to use the Read Modified Fields
(QsnReadMDT) API in conjunction with the buffer query APIs. The resulting
screen display before and after the input operations is shown in
<a href="#FIGLLEX3A">Figure 6</a> and <a href="#FIGLLEX3B">Figure 7</a>,
respectively.</p>
<p><strong><a name="FIGLLEX3">Figure 5. Program Using Read Modified Fields (QsnReadMDT) API</a></strong></p>
<table border>
<tr>
<td>
<pre>
#include &lt;stdlib.h&gt;
#include &lt;stdio.h&gt;
#include &lt;string.h&gt;
#include &quot;qsnapi.h&quot;
#define TRUE 1
#define FALSE 0
int main(void)
{
Q_Bin4 i, t1, t2, t3, numflds;
const Q_Uchar cc1=QSN_CC1_MDTALL_CLRALL, cc2=QSN_CC2_UNLOCKBD;
const Q_Uchar nosa = QSN_NO_SA, norm = QSN_SA_NORM, saul = QSN_SA_UL;
char pad = ' ';
Qsn_Cmd_Buf_T cmdbuf, cmdbuf2;
Qsn_Inp_Buf_T inpbuf;
Qsn_Fld_Inf_T fldqry;
Qsn_Read_Inf_T rdqry;
char msg[100];
Q_Fdbk_T fdbk = { sizeof(Q_Fdbk_T) };
cmdbuf = QsnCrtCmdBuf(100, 50, 0, NULL, NULL);
cmdbuf2 = QsnCrtCmdBuf(100, 50, 0, NULL, NULL);
inpbuf = QsnCrtInpBuf(200, 50, 0, NULL, NULL);
QsnClrScr('0', 0, 0, NULL);
QsnWTD(cc1, cc2, cmdbuf, 0, NULL);
while (TRUE) {
QsnSetFld(0, 10, 3, 2, QSN_FFW_ALPHA_SHIFT, NULL, 0, saul,
saul, cmdbuf, 0, NULL);
QsnSetFld(0, 10, 5, 2, QSN_FFW_ALPHA_SHIFT, NULL, 0, saul,
saul, cmdbuf, 0, NULL);
QsnSetFld(0, 10, 7, 2, QSN_FFW_ALPHA_SHIFT, NULL, 0, saul,
saul, cmdbuf, 0, NULL);
numflds = QsnReadMDT(QSN_CC1_NULL, QSN_CC1_NULL, NULL,
inpbuf, cmdbuf, 0, NULL);
if (QsnRtvReadAID(inpbuf, NULL, NULL) == QSN_F3)
break;
QsnPutBuf(cmdbuf2, 0, NULL);
QsnClrBuf(cmdbuf2, NULL);
QsnClrBuf(cmdbuf, NULL);
QsnWTD(cc1, cc2, cmdbuf, 0, NULL);
sprintf(msg, &quot;Num Fields Change: %d&quot;, numflds);
QsnWrtDta(msg, strlen(msg), 0, 2, 30, norm, norm, norm, norm,
cmdbuf, 0, NULL);
for (i = 1; i &lt;= numflds; i++) {
fldqry.len = 0;
if (QsnRtvFldInf(inpbuf, i, &amp;fldqry, sizeof(fldqry),
0, &amp;fdbk) != QSN_FAIL) {
sprintf(msg,
&quot;Field# %d, row %d, col %d, len %d, value %.*s&quot;,
i, fldqry.row, fldqry.col, fldqry.len,
fldqry.len, fldqry.data);
QsnWrtDta(msg, t1=strlen(msg), 0,
t2=i+3, t3=30, norm, norm, norm, norm,
cmdbuf, 0, NULL);
QsnWrtPad(pad, t1, 0, t2, t3, cmdbuf2, 0, NULL);
} else {
sprintf(msg, &quot;Field query failed&quot;);
QsnWrtDta(msg, t1=strlen(msg), 0,
t2=4, t3=30, norm, norm, norm, norm,
cmdbuf, 0, NULL);
QsnWrtPad(pad, t1, 0, t2, t3, cmdbuf2, 0, NULL);
}
}
</pre>
</td>
</tr>
</table>
<table border>
<tr>
<td>
<pre>
QsnRtvReadInf(inpbuf, &amp;rdqry, sizeof(rdqry), 0, NULL);
sprintf(msg, &quot;Read information:&quot;);
QsnWrtDta(msg, strlen(msg), 0, t2=10, t3=2, norm, norm,
norm, norm, cmdbuf, 0, NULL);
QsnWrtPadAdr(pad, -1, -1, t2, t3, cmdbuf2, 0, NULL);
sprintf(msg, &quot;Bytes returned %d, available: %d&quot;,
rdqry.bytes_returned, rdqry.bytes_available);
QsnWrtDta(msg, strlen(msg), 0, ++t2, t3+2, norm, norm,
norm, norm, cmdbuf, 0, NULL);
sprintf(msg, &quot;First data byte: %p&quot;, rdqry.dta);
QsnWrtDta(msg, strlen(msg), 0, ++t2, t3+2, norm, norm,
norm, norm, cmdbuf, 0, NULL);
sprintf(msg, &quot;First field byte: %p&quot;, rdqry.fld_dta);
QsnWrtDta(msg, strlen(msg), 0, ++t2, t3+4, norm, norm,
norm, norm, cmdbuf, 0, NULL);
sprintf(msg, &quot;Diff: %d&quot;, rdqry.fld_dta-rdqry.dta);
QsnWrtDta(msg, strlen(msg), 0, ++t2, t3+4, norm, norm,
norm, norm, cmdbuf, 0, NULL);
sprintf(msg,
&quot;Read len: %d, data len: %d, field data len: %d,\
num fields: %d&quot;,
rdqry.read_len, rdqry.dta_len, rdqry.fld_dta_len,
rdqry.num_flds);
QsnWrtDta(msg, strlen(msg), 0, ++t2, t3+2, norm, norm,
norm, norm, cmdbuf, 0, NULL);
sprintf(msg, &quot;Read row: %d, col: %d, aid: %x&quot;,
rdqry.read_row, rdqry.read_col, rdqry.AID);
QsnWrtDta(msg, strlen(msg), 0, ++t2, t3+2, norm, norm,
norm, norm, cmdbuf, 0, NULL);
}
}
</pre>
</td>
</tr>
</table>
<br>
<br>
<p><strong><a name="FIGLLEX3A">Figure 6. Display Screen before Input Operation</a></strong></p>
<table border>
<tr>
<td>
<pre>
+--------------------------------------------------------------------------------+
| |
| |
| field 1 |
| |
| field 2 |
| |
| field 3 |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
+--------------------------------------------------------------------------------+</pre>
</td>
</tr>
</table>
<br>
<br>
<p><strong><a name="FIGLLEX3B">Figure 7. Display Screen after Input Operation</a></strong></p>
<table border>
<tr>
<td>
<pre>
+--------------------------------------------------------------------------------+
| |
| Num Fields Change: 3 |
| __________ |
| Field# 1, row 3, col 2, len 7, value field 1 |
| __________ Field# 2, row 5, col 2, len 9, value field 2 |
| Field# 3, row 7, col 2, len 7, value field 3 |
| __________ |
| |
| |
| Read information: |
| Bytes returned 80, available: 80 |
| First data byte: SPP:0000 :1aefQPADEV0010JENNIFER 002600 :19b:0:d42 |
| First field byte: SPP:0000 :1aefQPADEV0010JENNIFER 002600 :19e:1:d42 |
| Diff: 3 |
| Read len: 35, data len: 35, field data len: 32, num fields: 3 |
| Read row: 3, col: 2, aid: f1 |
| |
| |
| |
| |
| |
| |
| |
| |
+--------------------------------------------------------------------------------+</pre>
</td>
</tr>
</table>
<br>
<br>
<h3><a name="HDRLLEX4">Low-Level Services Example--4</a></h3>
<p>The sample program in Figure 8 shows how to use the QsnWrtSFMaj and QsnWrtSFMin
APIs to display a window on the screen using the 5250 Create Window command. See the
<cite>5494 Remote Control Unit Functions Reference R3.1</cite>,
SC30-3533-04, for more information. This book can be viewed online through the
<a href="http://www.elink.ibmlink.ibm.com/public/applications/publications/cgibin/pbi.cgi?CTY=US">
IBM Publications Center</a><img src="www.gif" alt="Link outside Information Center">.</p>
<p><strong><a name="FIGLLEX4">Figure 8. Program Using Read QsnWrtSFMaj and QsnWrtSFMin APIs</a></strong></p>
<table border>
<tr>
<td>
<pre>
#include &lt;stdlib.h&gt;
#include &lt;stdio.h&gt;
#include &lt;string.h&gt;
#include &quot;qsnapi.h&quot;
#define STRUCTURED_FIELD '\xd9'
#define CREATE_WIN_STRUCTURED_FIELD '\x51'
#define WINDOW_CURSOR_RESTRICT '\x80'
#define WINDOW_PULL_DOWN '\x40'
#define WINDOW_BORDER_MINOR '\x01'
#define WINDOW_TITLE_MINOR '\x10'
typedef _Packed struct {
Q_Bin2 length;
Q_Uchar class;
Q_Uchar type;
Q_Uchar flag1;
Q_Uchar flag2;
Q_Uchar reserved;
Q_Uchar num_rows;
Q_Uchar num_cols;
} create_window_major;
typedef _Packed struct {
Q_Uchar length;
Q_Uchar type;
Q_Uchar flag1;
Q_Uchar mono_attr;
Q_Uchar color_attr;
Q_Uchar ul;
Q_Uchar top;
Q_Uchar ur;
Q_Uchar left;
Q_Uchar right;
Q_Uchar ll;
Q_Uchar bottom;
Q_Uchar lr;
} create_window_border_minor;
typedef _Packed struct {
Q_Uchar length;
Q_Uchar type;
Q_Uchar flag1;
Q_Uchar mono_attr;
Q_Uchar color_attr;
Q_Uchar reserved;
} create_window_title_minor;
</pre>
</td>
</tr>
</table>
<br>
<table border>
<tr>
<td>
<pre>
int main(void)
{
create_window_major win;
create_window_border_minor win_border;
create_window_title_minor win_title;
Qsn_Cmd_Buf_T cmdbuf;
Q_Uchar c1;
char title_text[] = &quot;Title&quot;;
cmdbuf = QsnCrtCmdBuf( 300, 20, 0, NULL, NULL);
/* setup Create window command major structure */
win.length = sizeof(win);
win.class = STRUCTURED_FIELD;
win.type = CREATE_WIN_STRUCTURED_FIELD;
win.flag1 = WINDOW_CURSOR_RESTRICT;
win.flag2 = '\x00';
win.reserved = '\x00';
win.num_rows = 10;
win.num_cols = 10;
/* write Create window command major structure to command buffer */
QsnWrtSFMaj((char *)(&amp;win), sizeof(win), 0, 9, 22, cmdbuf, 0, NULL);
/* setup border presentation minor structure */
win_border.length = sizeof(win_border);
win_border.type = WINDOW_BORDER_MINOR;
win_border.flag1 = '\x00';
win_border.mono_attr = QSN_SA_RI;
win_border.color_attr = QSN_SA_PNK;
win_border.ul = '+';
win_border.top = '*';
win_border.ur = '+';
win_border.left = '-';
win_border.right = '|';
win_border.ll = '+';
win_border.bottom = '*';
win_border.lr = '+';
/* write border presentation minor structure to command buffer */
QsnWrtSFMin((char *)(&amp;win_border), sizeof(win_border), cmdbuf, 0, NULL);
/* setup window title minor structure */
win_title.length = sizeof(win_title) + strlen(title_text);
win_title.type = WINDOW_TITLE_MINOR;
win_title.flag1 = '\x00';
win_title.mono_attr = QSN_SA_BL;
win_title.color_attr = QSN_SA_RED;
win_title.reserved = '\x00';
/* write window title minor structure to command buffer */
QsnWrtSFMin((char *)(&amp;win_title), sizeof(win_title), cmdbuf, 0, NULL);
/* write title text to command buffer */
QsnWrtDta(title_text, strlen(title_text), 0, 0, 0,
QSN_NO_SA, QSN_NO_SA, QSN_NO_SA, QSN_NO_SA, cmdbuf, 0, NULL);
/* write command buffer to screen and wait for key-press */
QsnPutBuf(cmdbuf, 0, NULL);
QsnGetAID(NULL, 0, NULL);
}
</pre>
</td>
</tr>
</table>
<br>
<br>
<hr>
<center>
<table cellpadding="2" cellspacing="2">
<tr align="center"><td valign="middle" align="center">
<a href="#Top_Of_Page">Top</a> |
<a href="dsm.htm">Dynamic Screen Manager APIs</a> |
<a href="aplist.htm">APIs by category</a>
</td></tr>
</table>
</center>
</body>
</html>