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

183 lines
6.9 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>Using Session I/O APIs</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>Using Session I/O APIs</h2>
<h3><a name="HDRSSPERF">Performance Considerations</a></h3>
<p>Specifying EBCDIC control-character options on the session description can
incur overhead. Additional processing is required to handle these. Specifying
the scroller line and character display as immediate can incur additional
overhead. An output operation will occur for each line or group of characters
written. If you need to write multiple lines to the scroller, you can achieve
better performance by delaying line display until all the lines are written.
Then you can use the Display Scroller Bottom (QsnDspSclB) API to display the
data on the screen.</p>
<br>
<h3><a name="HDRSSEX">Create Session and Read Data--Example</a></h3>
<p>The sample program in Figure 1 shows how to create and read data from a
session. The resulting screen output is shown in <a href="#FIGSSEX1A">Figure 2</a>.</p>
<p><strong><a name="FIGSSEX1">Figure 1. Program for Creating a Session and
Reading Data</a></strong></p>
<pre>
#include &lt;stddef.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;
#include &lt;stdio.h&gt;
#include "qsnapi.h"
#define TRUE 1
#define FALSE 0
#define PF1 "PF4 - Move PF5 - Resize"
#define PF2 "PF6 - Print"
typedef struct {
Qsn_Ssn_Desc_T sess_desc;
char buffer[100];
} storage_t;
int main (void)
{
Qsn_Inp_Buf_T ibuf = 0;
char *fld_dta;
int i;
char text[100];
storage_t storage;
Qsn_Ssn_T session1;
Qsn_Ssn_Desc_T *sess_desc = (Qsn_Ssn_Desc_T *) &amp;storage;
Qsn_Win_Desc_T win_desc;
Q_Bin4 win_desc_length = sizeof(win_desc);
char *pf1 = PF1;
Q_Bin4 pf1_len = sizeof(PF1) - 1;
char *pf2 = PF2;
Q_Bin4 pf2_len = sizeof(PF2) - 1;
Q_Bin4 sess_desc_length = sizeof(Qsn_Ssn_Desc_T) + pf1_len +
pf2_len;
/* initialize and set up session and window descriptions */
QsnInzSsnD( sess_desc, sess_desc_length, NULL);
QsnInzWinD( &amp;win_desc, win_desc_length, NULL);
sess_desc-&gt;cmd_key_desc_line_1_offset = sizeof(Qsn_Ssn_Desc_T);
sess_desc-&gt;cmd_key_desc_line_1_len = pf1_len;
memcpy( storage.buffer, pf1, pf1_len );
sess_desc-&gt;cmd_key_desc_line_2_offset = sizeof(Qsn_Ssn_Desc_T) +
pf1_len;
sess_desc-&gt;cmd_key_desc_line_2_len = pf2_len;
memcpy( storage.buffer + pf1_len, pf2, pf2_len );
sess_desc-&gt;scl_line_dsp = '1';
sess_desc-&gt;scl_chr_dsp = '1';
sess_desc-&gt;num_input_line_rows = 2;
sess_desc-&gt;wrap = '0';
QsnCrtSsn( sess_desc, sess_desc_length, NULL, 0, '1',
&amp;win_desc, win_desc_length, NULL, 0,
&amp;session1, NULL);
if (ibuf == 0)
ibuf = QsnCrtInpBuf(100, 50, 0, NULL, NULL);
while ( TRUE ) {
QsnReadSsnDta( session1, ibuf, NULL, NULL);
/* check if any data read, then end if exit entered */
if ( (fld_dta=QsnRtvFldDta(ibuf, NULL, NULL)) != NULL) {
if (strncmp(fld_dta, "exit", 4) == 0)
break;
}
}
}
</pre>
<br>
<br>
<p><strong><a name="FIGSSEX1A">Figure 2. Screen Output from Create Session
Program</a></strong></p>
<table border>
<tr>
<td>
<pre>
+--------------------------------------------------------------------------------+
| ..............................................................................|
| : &gt; this is line 1 :|
| : &gt; this is line 2 :|
| : &gt; more lines :|
| : &gt; more data :|
| : &gt; another line :|
| : :|
| : :|
| : :|
| : :|
| : :|
| : :|
| : :|
| : :|
| : :|
| : :|
| : :|
| : ===&gt; __________________________________________________________________:|
| : ________________________________________________________________________ :|
| : F4=Move F5=Resize :|
| : F6=Print :|
| : :|
| :............................................................................:|
| |
+--------------------------------------------------------------------------------+
</pre>
<br>
</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>