PPWIZARD is a free preprocessor for HTML, REXX, Visual Basic or any text files.
[Bottom][Contents][Search][Prev]: REXAMPLE.X[Next]: REXAMPLE.REX (generated output)
\ -> Examples / Tips -> Rexx Preprocessing -> Rexx Example -> REXAMPLE.XH

REXAMPLE.XH

;----------------------------------------------------------------------------
;    MODULE NAME:   REXAMPLE.XH
;
;        $Author:   USER "Dennis"  $
;      $Revision:   1.0  $
;          $Date:   30 Mar 2001 18:05:34  $
;       $Logfile:   C:/DBAREIS/Projects.PVCS/MultiOs/PPWIZARD/rexample.xh.pvcs  $
;
;    DESCRIPTION:   Small example header file.
;
;----------------------------------------------------------------------------

/*
 * $Header:   C:/DBAREIS/Projects.PVCS/MultiOs/PPWIZARD/rexample.xh.pvcs   1.0   30 Mar 2001 18:05:34   USER "Dennis"  $
 */

/*--- Something in this header needs a feature introduced in "99.249" -------*/
#require   99.249

/*--- Skip past rexx routines -----------------------------------------------*/
<?RexxSkip>


#ifdef INCL_AddCommas2DecimalNumber
/*===========================================================================*/
AddCommas2DecimalNumber:                                   /* Integers Only! */
                       #ifdef Procedure
                              <$Procedure>
                       #endif
/*===========================================================================*/
   /*--- Get number return it it we already have commas ---------------------*/
   #NextId
   @@NoComma = strip( arg(1) );
   if  pos(',', @@NoComma) <> 0 then
       return(@@NoComma);

   /*--- split at possible decimal point ------------------------------------*/
   @@DotPos = pos('.', @@NoComma);
   if  @@DotPos = 0 then
       @@AfterDecimal = '';
   else
   do
       /*--- There is a decimal component -----------------------------------*/
       if  @@DotPos = 1 then
           return("0" || @@NoComma);
       @@AfterDecimal = substr(@@NoComma, @@DotPos+1);
       @@NoComma      = left(@@NoComma, @@DotPos-1);
   end;

   /*--- Reverse the integer ------------------------------------------------*/
   @@NoComma = reverse(@@NoComma);

   /*--- Grab 3 digits at a time --------------------------------------------*/
   @@ResultWithCommas = "";
   do  while length(@@NoComma) > 3
       @@ResultWithCommas = @@ResultWithCommas || left(@@NoComma, 3) || ',';
       @@NoComma          = substr(@@NoComma, 4);
   end;
   @@ResultWithCommas = @@ResultWithCommas || @@NoComma;

   /*--- Reverse the string and add decimal component -----------------------*/
   @@ResultWithCommas = reverse(@@ResultWithCommas)
   if  @@AfterDecimal <> '' then
       @@ResultWithCommas = @@ResultWithCommas || '.' || @@AfterDecimal;
   return(@@ResultWithCommas);
#endif



#ifdef INCL_GetAmPmTime
/*===========================================================================*/
GetAmPmTime:                         /* Fixed length AM/PM time with seconds */
                       #ifdef Procedure
                              <$Procedure>
                       #endif
/*===========================================================================*/
   #NextId
   @@CivilTime  = time('C');  if length(@@CivilTime)  = 6 then @@CivilTime=' '@@CivilTime;
   @@NumSeconds = ':'substr(time(), 7, 2);
   return( insert(@@NumSeconds, @@CivilTime, 5) );       /* Insert # seconds */
#endif



#ifdef INCL_StringReplace
/*===========================================================================*/
StringReplace:               /* Too tricky & limiting to set up as procedure */
/*===========================================================================*/
   /*--- Get the passed parameters ------------------------------------------*/
   #NextId
   @@String       = arg(1);
   @@ChangeFrom   = arg(2);
   @@ChangeTo     = arg(3);
   @@ChangeCntVar = arg(4);                          /* Passed by reference! */

   /*--- Look for the search string -----------------------------------------*/
   @@ChangeFromLength = length(@@ChangeFrom);
   @@ChangeToLength   = length(@@ChangeTo);
   @@FoundPosn        = pos(@@ChangeFrom, @@String);
   @@ChangesMade      = 0;
   do  while @@FoundPosn <> 0
       /*--- Perform the substitution ---------------------------------------*/
       @@String = left(@@String, @@FoundPosn-1) || @@ChangeTo || substr(@@String, @@FoundPosn+@@ChangeFromLength);

       /*--- Look for the more occurances of the search string --------------*/
       @@FoundPosn = pos(@@ChangeFrom, @@String, @@FoundPosn+@@ChangeToLength);
       @@ChangesMade = @@ChangesMade + 1;
   end;

   /*--- Update the change counter and return to the caller -----------------*/
   if  @@ChangeCntVar <> "" then
       interpret @@ChangeCntVar || " = @@ChangesMade + " || @@ChangeCntVar;
   return(@@String);
#endif



/*--- End of header file ----------------------------------------------------*/
<?RexxSkipTo>


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

[Top][Contents][Search][Prev]: REXAMPLE.X[Next]: REXAMPLE.REX (generated output)


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