PPWIZARD is a free preprocessor for HTML, REXX, Visual Basic or any text files.
[Bottom][Contents][Search][Prev]: /FilterInput[Next]: /ForceRebuild
\ -> PPWIZARD Command Line -> Switches -> /FilterOutput

Switch /FilterOutput:RexxCmdFile

This is a PPWIZARD command line switch.

This will probably be a rarely used option. This switch allows you to translate all generated lines a line at a time. The mechanism provides the filter enough information to perform complex processing (in case required). Your filter program actually writes all output lines.

In most cases it would probably be easier to write a translation procedure as a separate step after PPWIZARD has completed (however sometimes this may not be practical).

The rexx filter code you identify will be passed the following arguments:

  1. The literal 'O' indicates that output is being filtered.

  2. The generated line without terminating newline.

  3. The name of the output file.

  4. The number of lines already generated to the file (starts at 0).

  5. The overall number of lines generated.

  6. The newline character(s) that need to terminate each line that you write. The value of the newline may change if /CrLf is used.

The following environment variables are also available for use:

  1. PPWIZARD_VER_OI
    This variable contains the version number of the interface used by this program. This version number will only change when PPWIZARD has been modified in such a way that existing output filters could break. It is recommended that you validate the interface in your filter.

  2. PPWIZARD_DEBUG
    This variable tells you the current debug state ('Y' means on). This can be modified by the #debug command or the "/debug" command line switch.

  3. Your Own Variables
    The filter program can create its own state variables in the environment, this is demonstrated in the example further on. You can also set environment variables with the built in SetEnv routine.

WHAT YOU RETURN

  1. If successful you should return the string "OK:" followed by the number of lines you wrote to the output file. For example you would return "OK:0" if you dropped the passed line.

  2. Any string that does not begin with "OK:" indicates an error. The message will be displayed and processing will stop.

EXAMPLE OF OUTPUT FILTER

/*************************************************/
/* Stupid non-useful example of an output filter */
/*************************************************/

/*--- Get ALL parameters ----------------------------------------------------*/
FilterType   = arg(1);
TheLine      = arg(2);
ToFile       = arg(3);
ToFileLine   = arg(4);                                     /* Written so far */
TotalLine    = arg(5);                                     /* Written so far */
NewLine      = arg(6);

/*--- Check "ONCE" if on correct interface (Actually checked twice) ---------*/
if  TotalLine = 0 then
do
   /*--- Filter written to interface version "98.132" -----------------------*/
   WrittenToFilterVer = "98.132";
   CallersVer         = GetEnv("PPWIZARD_VER_OI");
   if  CallersVer <> WrittenToFilterVer then
       return( 'FILTEROUT: Interface written to version ' || WrittenToFilterVer || ' (found ' || CallersVer || ')' );
end;

/*--- Get current debug state (output input line if debug is on) ------------*/
DebugOn = GetEnv("PPWIZARD_DEBUG");
if DebugOn = 'Y' then
   say 'FILTEROUT: #' || TotalLine+1 || ' -> ' || TheLine;

/*--- If first line drop (this is complicated by line counters not changing!)*/
if  TotalLine = 0 then
do
   /*--- Only drop the first "first" file! ----------------------------------*/
   if  GetEnv('FiltOut_0') = '' then
   do
       /*--- We wish to drop the 1st line -----------------------------------*/
       if  DebugOn = 'Y' then
           say '          We are dropping the first line of output';
       call SetEnv 'FiltOut_0', 'Line 0 dropped';
       return("OK:0");
   end;
end;

/*--- All lines reversed (except inserted 5th) ------------------------------*/
NumberOfLines = 1;
ToWrite       = reverse(TheLine);
if  TotalLine = 3 then
do
   /*--- We are inserting a line (generating 2) -----------------------------*/
   NumberOfLines = 2;
   ToWrite       = ToWrite || NewLine || 'This line was inserted after the 4th output line line!';
end;

/*--- Output the data -------------------------------------------------------*/
if  0 <> charout(ToFile, ToWrite || NewLine) then
   return('Write to "' || ToFile || '" failed!');
else
   return("OK:" || NumberOfLines);




/*===========================================================================*/
GetEnv:
/*                                                                           */
/* arg(1) : Name of environment variable.                                    */
/*===========================================================================*/
   return( value(arg(1),,'OS2ENVIRONMENT') );




/*===========================================================================*/
SetEnv:
/*                                                                           */
/* arg(1) : Name of environment variable.                                    */
/* arg(2) : New Value.                                                       */
/*                                                                           */
/* Returns original value of the environment variable.                       */
/*===========================================================================*/
   return( value(arg(1),arg(2),'OS2ENVIRONMENT') );


email me  any feedback, additional information or corrections.
See this page online (look for updates)

[Top][Contents][Search][Prev]: /FilterInput[Next]: /ForceRebuild


PPWIZARD Manual
My whole website and this manual itself was developed using PPWIZARD (free preprocessor written by Dennis Bareis)
Sunday November 05 2017 at 10:00am