home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 3 Comm / 03-Comm.zip / cs2pmm_m.zip / cs2pmm_m.cmd next >
OS/2 REXX Batch file  |  1999-11-15  |  24KB  |  568 lines

  1. /* GCP saved message to PMMail/2 format converter in REXX */
  2. /* For all machines
  3.         Purpose      :        Opens an existing Golden CommPass saved message file, extracts the message
  4.                                             records, and writes them out as a text file in the format anticipated
  5.                                             by PMMail/2.  User can then move the files to the appropriate PMMail/2
  6.                                             directory and 'import' them using the menu item
  7.                                             Folder->Re-Index
  8.         Filename     :        cs2PMM_m.cmd
  9.         Fileversion  :        0, 9-Nov-1999
  10.         OS & version :        OS/2 v 3.0, v 4.0
  11.         Author       :        [Bruce M. Judd] Bruce.Judd@innovative-engineering.com
  12.               ------------------------------
  13.     - COMMAND-LINE PARAMETERS -
  14.         Arg (1) = "-f"filename            /* Filename of message file, including extension */
  15.         - required - not case sensitive
  16.         Arg (1) = "-c"                            /* Starting value for output filenames */
  17.         - optional - not case sensitive
  18.         Arg (1) = "-d"                            /* Display debugging information during processing */
  19.         - optional - not case sensitive
  20.         Arg (2) = "-q"                            /* Quiet mode */
  21.         - optional - not case sensitive
  22.         Arg (2) = "-h"                            /* Display help text */
  23.         - optional - not case sensitive
  24.  
  25.     - ERROR HANDLING -
  26.         NONE
  27.  
  28.     - RETURN CODES -
  29.         NONE
  30.  
  31.     - DEPENDENCIES -
  32.         REXX utilities (REXXUTIL.dll)
  33.         CCALJUL.CMD     3880   4-02-96   9:52 Jaime C. Cruz REXX script, (public domain)
  34.         CDOW.CMD        2827   4-01-96  15:43 Jaime C. Cruz REXX script, (public domain)
  35.         CLEPYER.CMD     1239   3-28-96  15:20 Jaime C. Cruz REXX script, (public domain)
  36.  
  37.     - REVISION HISTORY -
  38.          9-Nov-1999 . BMJ: Created
  39. */
  40. /*======================================================================
  41.     Define constants for this procedure
  42.     ====================================================================*/
  43. _lineOutTerm = "0D0A"x                    /* <lf> <cr> */
  44. fhelpTemp = "cs2PMM_h.txt"
  45. logFile = "cs2PMM_m.log"
  46. helpFile = "cs2pmm_m.inf"
  47.  
  48. sDOW.0 = 7                                            /* DOW conversion table */
  49. sDOW.1 = "Sun,"
  50. sDOW.2 = "Mon,"
  51. sDOW.3 = "Tue,"
  52. sDOW.4 = "Wed,"
  53. sDOW.5 = "Thu,"
  54. sDOW.6 = "Fri,"
  55. sDOW.7 = "Sat,"
  56.  
  57. iMOY.0 = 12                                            /* MOY conversion table */
  58. iMOY.Jan = 01
  59. iMOY.Feb = 02
  60. iMOY.Mar = 03
  61. iMOY.Apr = 04
  62. iMOY.May = 05
  63. iMOY.Jun = 06
  64. iMOY.Jul = 07
  65. iMOY.Aug = 08
  66. iMOY.Sep = 09
  67. iMOY.Oct = 10
  68. iMOY.Nov = 11
  69. iMOY.Dec = 12
  70.  
  71. /*======================================================================
  72.     Define globals for this procedure and initialize
  73.     ====================================================================*/
  74. arg1 = 1                                                /* Seed the command-line parameter parsing loop */
  75. bdebug = 0                                            /* Operate in debug mode? */
  76. bHelpOnError = 0                                /* Flag to control amount of help text displayed */
  77. bnoisy = 1                                            /* Query, prompt, and pamper the user? */
  78. bprogIndicator = 1                            /* Travel direction */
  79. bTOF = 0                                                /* Flag that allows us to remove blank lines at the top of a msg */
  80. exitCode = 0                                        /* O.k. to begin with */
  81. fdestNameSeed = 0                                /* Default if caller supplies none */
  82. fsrcMsgsBase = ""                                /* Base of caller-supplied filename */
  83. fsrcMsgsExt = ""                                /* Extension of caller-supplied filename */
  84. ifilCount = 1                                        /* No. of GCP msg files found */
  85. irecCount = 1                                        /* No. of GCP msg records found in the file - seeded so first prompt msg will work */
  86. outDir = ""                                            /* Name of directory where .msg files will be written */
  87. smsg = "="                                            /* Seed for progress indicator */
  88.  
  89. /*======================================================================
  90.     Request external functions we will need and verify all needed
  91.     components are present.
  92.     ====================================================================*/
  93. Call RxFuncAdd "SysLoadFuncs", "RexxUtil", "SysLoadFuncs"
  94. If rc = 0 Then
  95.     Signal HELPREXXU
  96. Call SysLoadFuncs
  97.  
  98. Parse Upper Value SysSearchPath( "PATH", "jccaljul.cmd" ) With progDir "JCCALJUL.CMD"
  99.     If progDir = "" Then
  100.         Signal HelpJCCALJULDIR
  101. Parse Upper Value SysSearchPath( "PATH", "jcdow.cmd" ) With progDir "JCDOW.CMD"
  102.     If progDir = "" Then
  103.         Signal HelpJCDOWDIR
  104. Parse Upper Value SysSearchPath( "PATH", "jclepyer.cmd" ) With progDir "JCLEPYER.CMD"
  105.     If progDir = "" Then
  106.         Signal HelpJCLEPYERDIR
  107.  
  108. /* Parse the command-line parameters passed in by the caller */
  109. Parse Upper Arg argRemainder
  110. Do While argRemainder <> ""
  111.     Parse Var argRemainder "-"arg1 argRemainder
  112.     flagType = Left( arg1, 1 )
  113.     arg1 = SubStr( arg1, 2 )            /* Allows caller to use space between flag and data - or not */
  114.     Select
  115.         When flagType = "C" Then
  116.             Parse Var arg1 fdestNameSeed .
  117.  
  118.         When flagType = "D" Then Do
  119.             bdebug = 1
  120.         End /* Do */
  121.  
  122.         When flagType = "F" Then Do
  123.             If arg1 = "" Then                    /* Caller used a space */
  124.                 Parse Var argRemainder arg1 argRemainder
  125.             Parse Var arg1 fsrcMsgsBase "." fsrcMsgsExt .
  126.         End /* Do */
  127.  
  128.         When flagType = "H" Then
  129.             Signal HELPSYNTAX
  130.  
  131.         When flagType = "Q" Then
  132.             bnoisy = 0
  133.  
  134.         Otherwise
  135.             NOP                                                /* It was some argument we don't respect */
  136.  
  137.     End /* Select */
  138. End /* While */
  139.  
  140. /* Apply assumptions to the sourcefile name */
  141. If fsrcMsgsExt = "" Then
  142.     fsrcMsgsExt = "sav"
  143. fsrcMsgs = fsrcMsgsBase || "." || fsrcMsgsExt    /* Assemble the filename */
  144. If fsrcMsgsBase = "" Then
  145.     Signal HELPSOURCE
  146.  
  147. /* Validate the seed counter */
  148. If fdestNameSeed = "" | Verify( fdestNameSeed, "0123456789" ) Then
  149.     Signal HELPCOUNT
  150.  
  151. /* Give the caller confirmation that we interpreted the command-line correctly */
  152. If bnoisy Then Do
  153.     msgText = "Searching for messages in '" || fsrcMsgs || "'"
  154.     If bdebug <> 0 Then
  155.         msgText = msgText "in debug mode"
  156.     Call GenOutFileName
  157.     msgText = msgText _lineOutTerm || "First output file will be '" || fdestMsg ||"'"
  158.     Say msgText
  159.     rc = CharOut( , "__?__  O.k.? (Y) or N " )
  160.     Pull 1 answer 2 .
  161.     If answer = "N" Then                    /* If it's not o.k. to proceed, bail */
  162.         Signal ExitMsg
  163. End /* Do */
  164.  
  165. /* Build stem of available files to process */
  166. rc = SysFileTree( fsrcMsgs, findSrc, "F" )     /* Get names of matching files */
  167. If findSrc.0 = 0 Then
  168.     Signal HELPSOURCE                            /* Nothing to do */
  169.  
  170. /*======================================================================
  171.     Main
  172.     ====================================================================*/
  173. Address Cmd
  174. Do While ifilCount <= findSrc.0
  175.     bnoSkip = 1                                        /* We don't plan on skipping the current input file */
  176.     bgetHeader = 0                                /* Collecting header information? */
  177.     bgotRecord = 0                                /* Found a GCP msg record? */
  178.     irecCount = 0                                    /* No. of GCP msg records found in the file */
  179.     irecWritten = 0                                /* No. of PMMail/2 txt msg files written */
  180.  
  181.     fsrcMsgs = FileSpec( "name", SubStr( findSrc.ifilCount, 39 ) )
  182.     Parse Var fsrcMsgs outDir "."
  183.     outDir = outDir || ".FLD\"
  184.  
  185.     /* Check to see if any files exist already. */
  186.     rc = SysFileTree( outDir || "C*.msg", ctemp, "F" )     /* Get names of matching files */
  187.     If ctemp.0 <> 0 Then                     /* Will be = 0 if no files or direcotry doesn't exist yet */
  188.         If bnoisy Then Do
  189.             Say "The output directory '" || outDir || "' contains .msg files."
  190.             rc = CharOut( , "__?__  OverWrite them (Y) or N " )
  191.             Pull 1 answer 2 .
  192.             If answer = "N" Then            /* If it's not o.k. to proceed, bail */
  193.                 bnoSkip = 0
  194.         End /* Do */
  195.     /* Directory *may* not be there. */
  196.     'MkDir' outDir
  197.  
  198.     /* Find out where on the screen we are going to display our progress indicator */
  199.     Parse Value SysCurPos() With row col
  200.  
  201.     Call ClearFields                            /* Initialize */
  202.  
  203.     /* Open data file and reset pointer.  Note that if another REXX script has this file open we
  204.         may get nothing but blank, 0 length strings back from the LineIn routines ... don't know
  205.         why . BMJ . 2-Jun-96 */
  206.     rc = LineIn( fsrcMsgs, 1, 0 )
  207.  
  208.     Do While bnoSkip & lines( fsrcMsgs ) <> 0
  209.         Parse Value LineIn( fsrcMsgs ) With lineBuf
  210.         /* Get what might be a tag - insist that the tag start in col 1 - else we would catch
  211.             quoted msgs also. */
  212.         lineBufTag = Left( lineBuf, 3 )
  213.         Select
  214.             /* Check for the msg start flag and grab date if one is found */
  215.             When Compare( lineBufTag, "#: " ) = 0 Then Do
  216.                 /* Msgs which contain full quotations of other msgs will have lines that 'look like' they
  217.                     belong in the header - we use this flag to prevent these tripping us up. */
  218.                 bgetHeader = 1
  219.                 If bgotRecord Then
  220.                     Call CloseMsg                        /* End of present msg is implied */
  221.                 irecCount = irecCount + 1    /* Keep counter up-to-date */
  222.                 bgotRecord = 1                        /* Set flag - found at least 1 msg */
  223.                 Parse Var lineBuf (lineBufTag) smsgNo "S" ssection    /* Grab the msg No. and forum section No./name */
  224.                 Parse Var smsgNo smsgNo smsgType    /* Catches (P) rivate flags and the like */
  225.                 Parse Value LineIn( fsrcMsgs ) With lineBuf /* Grab Date & Time */
  226.                 lineBuf = Strip( lineBuf, "Both" )
  227.                 Parse Var lineBuf idateDay "-" sdatemonth "-" idateYear sdateTime .
  228.                 Call FormatDate
  229.  
  230.                 /* Test for index out of range */
  231.                 If fdestNameSeed - 1 + irecCount > 9999999 Then Do
  232.                     msgText = ,
  233.                         "Filename index has exceeded 9,999,999 which is the maximum allowed." _lineOutTerm || ,
  234.                         "Processing cannot continue - exiting."
  235.                     rc = LineOut( "STDERR", msgText )    /* Ensure that error is diaplayed if redirection is in effect */
  236.                     Leave                                        /* Do While */        
  237.                 End /* Do */
  238.             End    /* Do */
  239.  
  240.             When bgetHeader & lineBufTag = "Sb: " Then Do    /* Found subject */
  241.                 Parse Var lineBuf (lineBufTag) ssubject
  242.                 ssubject = Strip( ssubject )                /* Can't do this in the Parse */
  243.                 /* If the message is part of a thread, replace the previously acquired msg No. with the
  244.                     thread no., allowing us to sort by thread in PMMail/2. */
  245.                 If Left( ssubject, 1 ) = "#" Then Do            /* Msg is part of a thread */
  246.                     Parse Var ssubject "#" sthreadNew "-" ssubjectNew
  247.                     /* To be a real thread ID, it must be numeric and be followed by a '-' */
  248.                     If Verify( sthreadNew, "0123456789" ) = 0 Then
  249.                         If SubStr( ssubject, Length( sthreadNew ) + 2, 1 ) = "-" Then Do
  250.                             sthread = sthreadNew
  251.                             ssubject = ssubjectNew
  252.                         End /* Do */
  253.                 End /* Do */
  254.             End /* Do */
  255.  
  256.             When bgetHeader & lineBufTag = "Fm: " Then Do    /* Found From ID */
  257.                 Parse Var lineBuf (lineBufTag) lineBuf    /* Strip the tag and any following whitespace */
  258.                 lineBuf = Translate( lineBuf, , '>"' )    /* These are often, but not always, present */
  259.                 Parse Var lineBuf srealFrom "INTERNET:" sfrom .
  260.                 srealFrom = Strip( srealFrom, )        /* Get rid of whitespace */
  261.                 If sfrom = "" Then                            /* Swap 'em */
  262.                     Parse Value srealFrom || "00"x || sfrom With sfrom "00"x srealFrom
  263.                 End /* Do */
  264.  
  265.             When bgetHeader & lineBufTag = "To: " Then Do    /* Found To ID */
  266.                 Parse Var lineBuf (lineBufTag) lineBuf    /* Strip the tag and any following whitespace */
  267.                 lineBuf = Translate( lineBuf, , '>"' )    /* These are often, but not always, present */
  268.                 Parse Var lineBuf srealTo "INTERNET:" sto .
  269.                 srealTo = Strip( srealTo, )            /* Get rid of whitespace */
  270.                 If sto = "" Then                                /* Swap 'em */
  271.                     Parse Value srealTo || "00"x || sto With sto "00"x srealTo
  272.                 End /* Do */
  273.  
  274.             When bgetHeader & lineBufTag = "" Then Do
  275.                 bgetHeader = 0                    /* That's it - we have everything we want now */
  276.                 Call WriteHeader                /* Start a new msg file */
  277.                 bTOF = 1                                /* Start cleaning */
  278.                 End /* Do */
  279.  
  280.             Otherwise
  281.                 If bgotRecord & bgetHeader = 0 Then        /* Part of the msg - just pass it through */
  282.                     If bTOF & Length( linebuf ) = 0 Then
  283.                         Iterate
  284.                     bTOF = 0                            /* We're into the msg meat now */
  285.                     If LineOut( fdestMsg, linebuf ) <> 0 Then
  286.                         rc = LineOUt( "STDERR", "Failed on attempt to write message header" irecCount "to output file:" fdestMsg )
  287.  
  288.         End /* Select */
  289.  
  290.     End    /* Do While */
  291.  
  292.     /* Close last file also - assuming one was started */
  293.     If bgotRecord Then                         /* Clear our buffer */
  294.         Call CloseMsg                                /* End of present msg is implied */
  295.     rc = SysCurPos( row, 0 )            /* Reset to beginning of line on which we displayed the progress indicator */
  296.     msgText = " - We wrote" irecWritten "record"
  297.     If irecWritten <> 1 Then                /* Long live Strunk & White */
  298.         msgText = msgText || "s to .msg files"
  299.     Else
  300.         msgText = msgText "to a .msg file"
  301.     Say msgText
  302.     ifilCount = ifilCount + 1            /* Next file in stem */
  303. End    /* Do While */
  304.  
  305. rc = SysCurPos( row, 0 )                /* Reset to beginning of line on which we displayed the progress indicator */
  306.  
  307. ExitMsg:
  308. Call ShowTrailer
  309. Exit( exitCode )
  310.  
  311. /*======================================================================
  312.     Local Functions
  313.     ====================================================================*/
  314. ClearFields:
  315.     Parse Value "" With ,
  316.     1 smsgNo,
  317.     1 sthread,
  318.     1 smsgType,
  319.     1 ssection,
  320.     1 sfrom,
  321.     1 srealFrom,
  322.     1 sto,
  323.     1 srealTo,
  324.     1 ssubject,
  325.     1 sdateDay,
  326.     1 idateDay,
  327.     1 sdateMonth,
  328.     1 idateYear,
  329.     1 sdateTime
  330. Return /* ClearFields */
  331.  
  332. WriteHeader:
  333.     Call ShowProgress                            /* Let user know something is going on */
  334.     Call GenOutFileName                        /* Build based on seed, etc. */    
  335.  
  336.     /* Remove any existing output file.  A bit of error checking on the rc here would be nicer ..... */
  337.     rc = SysFileDelete( fdestMsg )
  338.  
  339.     /* Format the msg No. & (if it's not received Mail) the threadID - ASCII sorting w/in
  340.         PMMail/2 is assumed.  Mail isn't threaded, so msgNo.'s there provide no information. */
  341.     If Compare( Translate( Left( ssection, 17 ) ), "0/COMPUSERVE MAIL" ) > 0 Then Do
  342.         If sthread = ""    Then                    /* Use the msg No. if not part of a thread so that sorting will work */
  343.             sthread = smsgNo
  344.         sthread = Right( sthread, 6, "." )
  345.         srealFrom = '"S' || ssection || '"'
  346.         srealTo = '"' || sthread || '"'
  347.     End /* Do */
  348.  
  349.     /* Write the message header out in PMMail-recognized txt format.  The trailing blank line is
  350.         the trigger to PMMail/2 that there is no more header information. The CSI msg No. and msg
  351.         'Type' is scrap data, but we keep everything. */
  352.     hdrText = ,
  353.         "From -"                                                                    || _lineOutTerm || ,
  354.         "From:" srealFrom "<" || sfrom || ">"                    || _lineOutTerm || ,
  355.         "To:" srealTo "<" || sto || ">"                        || _lineOutTerm || ,
  356.         "Subject:" ssubject                                                || _lineOutTerm || ,
  357.         "Date:" sdateDay idateDay sdateMonth idateYear sdateTime    || _lineOutTerm || ,
  358.         "CSI_Msg_No:" smsgNo smsgType                            || _lineOutTerm
  359.     rc = LineOut( fdestMsg, hdrText )
  360.     If rc <> 0 Then
  361.         rc = LineOut( "STDERR", "Failed on attempt to write message header" irecCount "to output file:" fdestMsg )
  362.     Else
  363.         irecWritten = irecWritten + 1
  364.  
  365.     /* Line termination is not handled correctly by the LineIn above.  The function seems to get
  366.         hung on the <cr> and not advance to the next line .....? The following will move it to the
  367.         beginning of the next line. */
  368.     if C2D( CharIn( fnsAddrFile ) ) = 13 Then
  369.         rc = LineIn( fnsAddrFile )
  370.  
  371.     /* Display debugging info if requested */
  372.     If bdebug Then Do
  373.         msgText = ,
  374.             "Found msg From: '" || sfrom || "'"                            _lineOutTerm || ,
  375.             "  to addressee: '" || sto || "'"                             _lineOutTerm || ,
  376.             "            re: '" || ssubject || "'"                         _lineOutTerm || ,
  377.             "  No. / thread: '" || sthread || "'"                         _lineOutTerm || ,
  378.             "         dated: '" || sdateDay sdateMonth idateYear sdateTime || "'"
  379.         Say msgText
  380.         rc = SysSleep( 0.25 )                /* Just enough for user to glimpse the report */
  381.     End /* Do */
  382.     Call ClearFields                            /* Reset data fields */
  383. Return /* WriteRecord */
  384.  
  385. FormatDate:
  386.     If sdateYear < 31 Then                /* Make Y2k ready *;-[] */
  387.         idateYear = "20" || idateYear    
  388.     Else
  389.         idateYear = "19" || idateYear
  390.  
  391.     /* Late in 1998 CSI stopped padding the day value with 0,s - fix that */
  392.     idateDay = Right( idateDay, 2, "0" )
  393.  
  394.     /* Determine the Day-of-week for the message date - CSI doesn't supply this */
  395.  
  396.     rc = JCDOW( JCCALJUL( Value( iMOY.sdateMonth ) idateDay idateYear ) )
  397.     sdateDay = sDOW.rc
  398.  
  399.     /* A real PMMail/2 sneak - if the time value is imcomplete, the displayed Msg Date is
  400.         the file date instead of what's stored in the header.  Test the time value and repair
  401.         if incomplete. */
  402.     Parse Var sdateTime ihrs ":" imin ":" isec
  403.     If ihrs = "" Then ihrs = "00"
  404.     If imin = "" Then imin = "00"
  405.     If isec = "" Then isec = "00"
  406.     sdateTime = ihrs || ":" || imin || ":" || isec
  407. Return /* FormatDate */
  408.  
  409. CloseMsg:
  410. rc = Lineout( fdestMsg )                /* Close current output file */
  411. Return /* CloseMsg */
  412.  
  413. ShowProgress:
  414.     iprogIndicator = irecCount // 10
  415.     If iprogIndicator = 0 Then
  416.         bprogIndicator = -bprogIndicator
  417.     If bprogIndicator = 1 Then
  418.         smsg = "=>"
  419.     Else Do
  420.         smsg = "< "
  421.         iprogIndicator = 10 - iprogIndicator
  422.     End /* Do */    
  423.     rc = SysCurPos( row, iprogIndicator )
  424.     rc = CharOut( "STDERR", smsg )
  425.     If bdebug & bnoisy Then
  426.         rc = SysSleep( 0.15 )                /* Just enough that user can tell conversion is progressing */
  427. Return /* ShowProgress */
  428.  
  429. GenOutFileName:
  430. fdestMsg = outDir || "C" || Right( fdestNameSeed + irecCount - 1, 7, "0" ) || ".msg"
  431. Return
  432.  
  433. ShowTrailer:
  434.     msgText = ,
  435.         "                    "                                        _lineOutTerm || ,
  436.         "==== End of run ===="                                        _lineOutTerm || ,
  437.         "We processed" ifilCount - 1 "input message file"
  438.         If ifilCount <> 2 Then                    /* Long live Strunk & White */
  439.             msgText = msgText || "s"
  440.     msgText = msgText                                                     _lineOutTerm || ,
  441.         "===================="                                        _lineOutTerm || ,
  442.         "cs2pmm_m GCP to PMMail/2 saved message conversion utility"    _lineOutTerm || ,
  443.         "  Freeware by Bruce M. Judd, v 0, 9-Nov-1999"            _lineOutTerm || ,
  444.         "  eMail: Bruce.Judd@innovative-engineering.com"            _lineOutTerm || ,
  445.         "===================="
  446.     rc = LineOut( "STDERR", msgText )
  447. Return /* ShowTrailer */
  448.  
  449. HELPINFDIR:
  450.     msgText = ,
  451.         "-Could not locate the helpfile Cs2PMM-m.inf.  Either         " _lineOutTerm
  452.     Signal HELPPATHDIR
  453. HelpJCCALJULDIR:
  454.     msgText = ,
  455.         "-Could not locate the required file JCCALJUL.cmd.  Either    " _lineOutTerm
  456.     Signal HELPPATHDIR
  457. HelpJCDOWDIR:
  458.     msgText = ,
  459.         "-Could not locate the required file JCDOW.cmd.  Either       " _lineOutTerm
  460.     Signal HELPPATHDIR
  461. HelpJCLEPYERDIR:
  462.     msgText = ,
  463.         "-Could not locate the required file JCLEPYER.CMD.  Either    " _lineOutTerm
  464.     Signal HELPPATHDIR
  465. HELPPATHDIR:
  466.     msgText = msgText || ,
  467.         "the file is missing, or it and Cs2PMM_m.cmd are not in a     " _lineOutTerm || ,
  468.         "directory which is listed in the system PATH statement.      " _lineOutTerm || ,
  469.         "The current path is:"
  470.     rc = LineOut( "STDERR", msgText )
  471.     '@echo %path%'
  472.     Signal HELPEND
  473. HELPREXXU:
  474.     Say "-Could not find the OS/2 REXX Utilities"
  475.     Signal HELPEND
  476. HELPSOURCE:
  477.     bHelpOnError = 1
  478.     Say "-Could not find any GCP message file(s) to match, '" || fsrcMsgs || "'"
  479.     Say " in the current directory."
  480.     Signal HELPSYNTAX;
  481. HELPCOUNT:
  482.     bHelpOnError = 1
  483.     Say "-The supplied -c[out] value, '" || fdestNameSeed || "', is not numeric."
  484.     Say " The value must be in the range 0 to 9,999,998"
  485.     Signal HELPSYNTAX;
  486. HELPSYNTAX:
  487.     shelpPhrase = ,                                /* Speed up the I/O */
  488.         "-The syntax at the command-line is:                                     " _lineOutTerm || ,
  489.         "     cs2pmm_m -f[ ]sourceFile [-c#######] [-d[ebug]] [-q[uiet] [-h[elp]]"
  490.     If bHelpOnError Then Do
  491.         rc = LineOut( "STDERR", shelpPhrase )
  492.         If bnoisy Then Do
  493.             rc = CharOut( , "__?__  Show more help? Y or (N) " )
  494.             Pull 1 answer 2 .    
  495.             If answer <> "Y" Then
  496.                 Signal HELPEND
  497.         End /* Do */
  498.         Else
  499.             Signal HELPEND
  500.     End /* Do */
  501.  
  502.     Parse Upper Value SysSearchPath( "PATH", "cs2pmm_m.cmd" ) With progDir "CS2PMM_M.CMD"
  503.     If progDir = "" Then
  504.         Signal HELPINFDIR
  505.     Else Do
  506.         '@start view' progDir || helpFile
  507.         Signal HELPEND
  508.     End /* Do */
  509. HELPTEXT:
  510.     shelpPhrase = shelpPhrase _lineOutTerm || _lineOutTerm || ,
  511.         "================= F3 or Alt-F4 to Exit this screen =================" _lineOutTerm || _lineOutTerm || ,
  512.         "-This program reads GCP saved message files only.                   " _lineOutTerm || _lineOutTerm || ,
  513.         "-The program must be executed from within the directory containing  " _lineOutTerm ,
  514.         " the source file(s) 'sourceFile'.  If no extension is supplied with " _lineOutTerm ,
  515.         " the 'sourcefile', '.sav' is assumed.  The output will be text      " _lineOutTerm ,
  516.         " file(s) named in the pattern 'C#######.msg' which will be placed in" _lineOutTerm ,
  517.         " a directory with the same base name as the 'sourcefile'.           " _lineOutTerm || _lineOutTerm || ,
  518.         "-For the benefit of 4OS2 users, a space is permitted between the -f " _lineOutTerm ,
  519.         " and the filename (that TAB key is fantastic! no?)                  " _lineOutTerm || _lineOutTerm || ,
  520.         "-The optional '-c#######' will be the value that the program uses to" _lineOutTerm ,
  521.         " construct the ####### portion of the filename of the output text   " _lineOutTerm ,
  522.         " file(s).  ####### is a numeric value starting at the supplied      " _lineOutTerm ,
  523.         " '-c#######'.  If 'count' is omitted, 0 is assumed.                 " _lineOutTerm || _lineOutTerm || ,
  524.         "-The optional '-d[ebug]' will cause the program to spout out a copy " _lineOutTerm ,
  525.         " of some of the header data fields for each found message record as " _lineOutTerm ,
  526.          " the program executes.  You can use the Pause / Enter keys to       " _lineOutTerm ,
  527.         " pause / continue program execution when running in debug mode.     " _lineOutTerm || _lineOutTerm || ,
  528.         "-The optional '-q[uiet]' will suppress all program output except for" _lineOutTerm ,
  529.         " error messages.                                                    " _lineOutTerm || _lineOutTerm || ,
  530.         "-The optional '-h[elp]' will cause the program to output this help  " _lineOutTerm ,
  531.         " text                                                               " _lineOutTerm ,
  532.         "====================================================================" _lineOutTerm || _lineOutTerm || ,
  533.         " The steps to import the output '.msg' files to PMMail/2 follow:    " _lineOutTerm || _lineOutTerm || ,
  534.         " 1. - Open PMMail/2 and create a new folder in the PMMail/2 account " _lineOutTerm ,
  535.         " to receive the new messages.  If you want the messages to be placed" _lineOutTerm ,
  536.         " in an existing folder, I still recommend creating this 'temporary' " _lineOutTerm ,
  537.         " folder; you can 'drag-n-drop', sort, filter, etc. the new messages " _lineOutTerm ,
  538.         " to any location and any account after they are imported.           " _lineOutTerm || _lineOutTerm || ,
  539.         " 2. - Go to the command-line, drill down to the PMMail/2 folder you " _lineOutTerm ,
  540.         " just created and then move all of the new 'C#######.msg' files     " _lineOutTerm ,
  541.         " into it.                                                           " _lineOutTerm || _lineOutTerm || ,
  542.         " 3. - Return to PMMail/2 and select the new folder; use             " _lineOutTerm ,
  543.         " Folder->Re-Index                                                   " _lineOutTerm ,
  544.         " to add the msg file(s) generated by this script to the folder.     " _lineOutTerm ,
  545.         "====================================================================" _lineOutTerm || _lineOutTerm || ,
  546.         "-Example Usage:                                                     " _lineOutTerm ,
  547.         "     cs2pmm_m -fos2user -c500 -d                                    " _lineOutTerm ,
  548.         " would translate the GCP saved message file named 'os2user.sav' from" _lineOutTerm ,
  549.         " the directory, would generate output message files starting with   " _lineOutTerm ,
  550.         " the name 'C0000500.msg', and would display debugging information   " _lineOutTerm ,
  551.         " for each message found during the process.                         "
  552.     If LineOut( fhelpTemp, shelpPhrase ) Then
  553.         Say "Failed on attempt to create helpfile '" || fhelpTemp || "' in the current directoory"
  554.     Else Do
  555.         rc = LineOut( fhelpTemp )                /* Close the file, else we can't open for reading! */
  556.         '@e' fhelpTemp
  557.         rc = SysFileDelete( fhelpTemp )
  558.     End /* Do */
  559. HELPEND:
  560.     Say _lineOutTerm "Cs2PMM_m: Exiting"
  561.     exitcode = 8        /* Made up value to indicate incorrect command line parameter was passed */
  562.     Exit( exitcode )
  563. Return /* Help */
  564.  
  565. /* End ============================================== Local Functions */
  566.  
  567. /* End ================================================= cs2PMM_m.cmd */
  568.