OnDemand User Group

Support Forums => MP Server => Topic started by: ssorich on October 05, 2017, 08:02:43 AM

Title: User exit in C - need advice
Post by: ssorich on October 05, 2017, 08:02:43 AM
We already have an exit that changes all x’00’ to x’20’... I donlt know C language, but I am trying to change only the value in column1 to spaces instead of all characters... Is anybody familiar with how to change the code to do so? Thanks!

Here is the source:
#include "apkexits.h"                                                           
                                                                     

char *recordptr; /* pointer to record to be analyzed */
int recordlen; /* length of record to be analyzed */

long ACIF_EXPORT INPEXIT( INPEXIT_PARMS *exitstruc)
{

   recordptr = exitstruc->record;
   recordlen = exitstruc->recordln;
   int cnt = 0;


   if(exitstruc->eof != INP_EOFLAG)
   {

      for (cnt = 0; cnt < recordlen; cnt++ ) {
         if ((unsigned char) exitstruc->record[cnt] == 0x00) {
            exitstruc->record[cnt] = 0x20;
         }
      }

      exitstruc->request = INP_USE;
   }

   return( 0 );
}
Title: Re: User exit in C - need advice
Post by: Justin Derrick on October 05, 2017, 01:37:04 PM
I'm not a C programmer, so I'm not super clear on what's inside that pointer you're being passed in that code. 

If it's a single line of a linedata report, then you could place restrictions on the position (i.e. array offset) of the characters that you're optionally replacing.

Alternately, if you're just getting a buffer of X characters, then you'd need to look for a line ending character followed immediately by the character you want to replace.

Hopefully some other folks with more experience can chime in and get you closer to a solution.

-JD.
Title: Re: User exit in C - need advice
Post by: ssorich on October 06, 2017, 09:03:19 AM
Thanks Justin - and agreed - it's one substring or array value from what I want t to be
Title: Re: User exit in C - need advice
Post by: Steve Bechtolt on February 02, 2018, 05:54:02 AM
Get rid of the for loop and use: exitstruc->record[0] = 0x20;