Userexits with Default- and Application Parameters

Userexits at edit_action-, pre_action-, and post_action-triggers of a mask are passed a default parameter as first parameter pr1 and the application parameter pr2 described above as second parameter. The length of the complete parameter string may not be longer than 255 characters.

The default parameter contains information on the current work mode of mask edit state pr1[0] and on the current row position pr1[1]. This information is required, for action triggers - as opposed to field triggers - are not called in mask edit state and thus the local memory does not contain such data at the time of invocation.

Default Parameter Current Work Mode Meaning
pr1[0] 'Q' Query Mode -> edit a search request
'I' Insert Mode -> insert a record
'C' Copy Mode -> copy a record
'U' Update Mode -> edit a record
'X' Replace-Mode -> exchanging child elements when editing records in relation tables
'T' Temporary Mode -> temporarily delete a record
'R' Rollback Mode -> rollback deleting a record
'D' Delete Mode -> finally delete a record
pr1[1] - Current row position as character value

If we consider the standard functional sequences, the following special rules apply for passing standard parameters:

Note! See also DTV User's Guide -> Masks and Fields -> Standard functional sequences in masks.

Query, Refresh records
After the actions in the functional sequence Query/Refresh (query, count, fetch) the triggers that are run through (Edit_Action-, Pre_Action- and Post_Action trigger) are always passed the Query mode without line numbers.

Copy records (incl. Copy&Paste, Drag&Drop)
When copying records, DataView will pass the Copy mode only at the Edit_Action trigger, i.e. before the editing of the record to be copied. Because this is basically an Insert operation into the target mask, Dataview will pass the Insert mode to the Pre_Action- and the Post_Action triggers.

Insert records
If Fetch after Write" is active (dal_wdh_set_chk_faw), a record is even read from the database again after it has been successfully created, i.e. saved. In this process the Query mode together with the current line number are also passed to the Pre_Action- and Post_Action triggers.

Edit records
After the editing process of a record has been cancelled, the old state must be restored in the mask. For this reason the record is read again from the database. In this process the Query mode together with the current line number are also passed to the Pre_Action- and Post_Action triggers.

If Fetch after Write" is active (dal_wdh_set_chk_faw), a record is even read from the database again after it has been successfully edited, i.e. saved. In this process the Query mode together with the current line number are also passed to the Pre_Action- and Post_Action triggers.

Delete records
DataView does not pass the work modes Temporary, Rollback and Delete at the Edit_Action trigger, because no editing process is carried out in case of Delete and Rollback operations.

Create relations
If child elements are exchanged in relation tables, this results in a change of the C_ID 2. Strictly speaking, an old relation is deleted and a new one is created. DataView passes the special Replace mode to the Pre_Action- and the Post_Action triggers for application-specific reactions to this process.

If you install userexits at the action triggers of a mask, almost always one userexit has to fulfill different tasks depending on the work mode passed in the default parameter. That's why as your first statement you always have to implement a switch controlling the branching into work modes as required.

Example: program structure of a userexit at the action trigger, printing the current work mode, the current row position and the application parameter.

integer func_action  (pr1, pr2)
char *pr1,
*pr2;
{
long row;
char mod;

mod = pr1[0]; current work mode

if (pr1[1])
sscanf (&pr1[1], "%d", &row); current row position
else row = 0;

  switch (mod)
{
case 'Q': if (!row)
printf ("query mode\n");
else
printf ("Break mode in row %d\n", row);
break;

  case 'I': printf ("Insert mode in row %d\n", row);
break;

  case 'C': printf ("Copy mode in row %d\n", row);
break;

  case 'U': printf ("Update mode in row %d\n", row);
break;

  case 'X': printf ("Replace-Modus in row %d\n", row);
break;

  case 'T': printf ("Temporary mode in row %d\n",row);
break;

  case 'R': printf ("Rollback mode in row %d\n", row);
break;

  case 'D': printf ("Delete mode in row %d\n", row);
break;

  default:  printf ("System error !\n");
break;
}

  printf ("Application parameter string = %s\n", pr2);
}