Loading...
Select Version
The forinput INPUT exit is called when data is input in the format mode, and it reacts to the input as follows:
User commands are initiated:
KDCOUT: Press the F1 key
KDCDISP: Press the F2 key
KDCOFF: the first character of the input is "/"; this is only accepted outside of a service.
If the user is also allowed to input KDCLAST and KDCFOR, then the program must be expanded accordingly.
This INPUT exit is generated with the KDCDEF statement EXIT:
KDCDEF statement
EXIT PROGRAM=FORINPUT,USAGE=(INPUT,FORMMODE)
Event exit INPUT
#include <string.h>
#include <kcinp.h>
#define KDCDISP 2
#define KDCOUT 1
#define NOKEY 0
#define FKEY 1
#define KDCOFF "KDCOFF "
#define NOTAC (strncmp (param->kcicfinf, "ON", 2) != 0)
#define CV_END (strncmp (param->kcicvst, "EC", 2) == 0)
#define TAC param->kcicvtac[0]
#define fkey param->kcifkey
#define cmd param->kcintac
#define nexttac param->kcintac
#define errcode param->kcierrcd
#define contcode param->kciccd
#define firstchar param->kcifch[0]
#define cut param->kcicut
static int key( struct kc_inp * );
static void func_control( struct kc_inp * );
static void cv_continue( struct kc_inp * );
void forinput ( struct kc_inp *param )
{
if ( key ( param ) == NOKEY) /* No F-key */
{ if ( CV_END)
func_control ( param );
else
cv_continue ( param );
}
}
/*************************************************************************/
/* function key for checking F-key */
/*************************************************************************/
int key ( struct kc_inp *param )
{
int key_value = NOKEY;
if (fkey > 0)
{ switch (fkey)
{
case KDCOUT:
memcpy (cmd, "KDCOUT ", 8);
memcpy (contcode, "CD", 2);
cut = ́N ́;
memset (errcode, ́ ́, 4);
key_value = FKEY;
break;
default: break;
}
}
return key_value;
}
/**************************************************************************/
/* function func_control: checking the next FUNCTION out of conversation*/
/************************************************************************ */
void func_control ( struct kc_inp * param )
{
if (firstchar == ́/ ́) /* check the first character*/
{ memcpy (cmd, KDCOFF, 8); /* of input: ́/ ́ = KDCOFF */
memcpy (contcode, "CD", 2);
cut = ́N ́;
memset (errcode, ́ ́, 4);
}
else /* check control field */
{
if (NOTAC) /* no input in control field*/
{ memset (nexttac, ́ ́, 8);
memcpy (contcode, "ER", 2);
cut = ́N ́;
memcpy (errcode, "ER01", 4);
}
else
{ switch (TAC) /* TAC for the next */
{ /* conversation */
case ́1 ́:
memcpy (nexttac, "DTAC1 ", 8);
memcpy (contcode, "SC", 2);
cut = ́Y ́;
memset (errcode, ́ ́, 4);
break;
case ́2 ́:
memcpy (nexttac, "DTAC3 ", 8);
memcpy (contcode, "SC", 2);
cut = ́Y ́;
memset (errcode, ́ ́, 4);
break;
case ́3 ́:
memcpy (nexttac, "DTAC6 ", 8);
memcpy (contcode, "SC", 2);
cut = ́Y ́;
memset (errcode, ́ ́, 4);
break;
default: /* TAC is invalid */
memset (nexttac, ́ ́, 8);
memcpy (contcode, "ER", 2);
cut = ́N ́;
memcpy (errcode, "ER02", 4);
break;
}
}
}
}
/*************************************************************************/
/* function cv_continue: continue the conversation */
/*************************************************************************/
void cv_continue ( struct kc_inp * param )
{ memset (nexttac, ́ ́, 8);
memcpy (contcode, "CC", 2);
cut = ́N ́;
memset (errcode, ́ ́, 4);
}