Invokes user exit routine, cexuser().

Available in:

Apps (win) Apps (char) Reportwriter RPC Standalone PL


string exec_usr (arg1,arg2,...,argn)
expr             arg1,arg2,...,argn


The runtime executor is linked with a sample routine (refer to the cexuser.c in Notes below). The method of passing parameters is similar to that of passing parameters to a C program:
char *cexuser(argc,argv)
int           argc;
char          argv[];
The difference is that argc contains the actual number of parameters; for example, argv[0] points to the first parameter. As in C, the parameters are all null-terminated (conversion is automatic). The exception is the TRIMpl clipboard which is implicitely passed as the last parameter, argv[argc]. The clipboard parameter is a pointer to a structure:
struct { 
  unsigned int   current_length;            /* the current length of the data */
  unsigned int   allocated_length;          /* the allocated clipboard length */
  unsigned char *data_ponter;               /* the clipboard data             */
  }         cb;

If your user exit code modifies the clipboard's contents, you must be sure to set the current_length to the correct value. The cexuser() return value must be a null-terminated string that is returned by the user exit function. If your application needs multiple user exits, insert a code as the first parameter to cexuser() which, in turn, contains a switch statement based on this code. The following is the code for cexuser(), a sample exit routine invoked by exec_usr(). The routine prints out the number of arguments, prints out each argument, and returns a message:

#include <stdio.h>

char *cexuser(argc,argv)
int           argc;          /* number of arguments */
char         *argv[];        /* array of arguments */
int i;                       /* loop variable */

printf("cexuser called with %d argument(s)\n\n",argc);
for (i=0;i<argc;i++) printf("arg%d: %s\n",i,argv[i]);
return("All is OK");


Assumes that cexuser.c does some special formatting on a single value.
new_value = exec_usr(SAL * 1.10);