Changeset 1716


Ignore:
Timestamp:
Feb 15, 2014, 9:01:31 PM (11 years ago)
Author:
John Small
Message:

Ticket 501: Fixed bug and improved error handling. Errors, if any, now logged to file.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/shdwmgr.cmd

    r1192 r1716  
    22 * $Id$
    33 *
    4  * ShdwMgr: Create Shadows for FM/2 installation */
     4 * ShdwMgr: Create Shadows for FM/2 installation
     5 *
     6 * 14 Feb 14  JBS Ticket 501: Corrected a syntax error and improved the error handling.
     7 *                            Errors are now logged to a file.
    58 *
    69 */
     
    912call SysLoadFuncs
    1013
    11 parse upper arg package_parm .
    12 if strip(package_parm) == '' then
    13    package_parm = 'FM2'
    14 else
    15    if wordpos(package_parm, 'FM2 FM2UTILS') = 0 then
    16       do
    17          say 'Invalid parameter: 'arg(1)
    18          say 'Program aborted....'
    19          '@pause'
    20          exit 1
    21       end
    22 
    2314parse source . . thispgm
    2415thisdir = left(thispgm, lastpos('\', thispgm) - 1)
     
    2617   thisdir = thisdir || '\'
    2718call directory thisdir
     19parse value filespec('N', thispgm) with program_stem '.' .
     20
     21parse upper arg package_parm .
     22if strip(package_parm) == '' then
     23   package_parm = 'FM2'
     24pkgnum = wordpos(package_parm, 'FM2 FM2UTILS')
     25
     26error_log = program_stem || pkgnum || '.err'
     27call SysFileDelete error_log              /* Delete previous error logs for this package */
     28errors = 0
     29
     30if pkgnum = 0 then
     31   do
     32      call lineout error_log, 'Invalid parameter:' package_parm
     33      call lineout error_log, 'Program aborted....'
     34      exit 1
     35   end
    2836
    2937i = 0
     
    6169         if fullfilename = '' then
    6270            do
    63                say 'Unable to find file: 'Shadow.i.filename
    64                say 'thisdir: 'thisdir
    65                '@pause'
    66                exit 1
     71               call lineout error_log, 'Unable to find file: 'Shadow.i.filename
     72               errors = errors + 1
    6773            end
    68          lenbytes = X2C( D2X( LENGTH( Shadow.i.longname ), 4 ))
    69          rc = SysPutEA( fullfilename, '.LONGNAME', X2C('FDFF') || REVERSE( lenbytes ) || Shadow.i.longname )
    70          if rc \= 0 then
     74         else
    7175            do
    72                say 'Error in setting .LONGNAME EA: 'rc
    73                say 'Exiting...'
    74                '@pause'
    75                exit 2
    76             end
    77          p = lastpos('\', Shadow.i.filename)
    78          if p > 0 then
    79             shadowidname = substr(Shadow.i.filename, p + 1)
    80          else
    81             shadowidname = Shadow.i.filename
    82          rc = SysCreateObject( 'WPShadow', Shadow.i.longname, Shadow.i.folderid , 'SHADOWID='fullfilename';OBJECTID=<FM3_Shadow_'shadowidname'>;', 'R')
    83          if rc \= 1 then
    84             do
    85                say 'Unable to create shadow object for :'Shadow.i.filename
    86                say 'Exiting...'
    87                '@pause'
    88                exit 3
     76               lenbytes = X2C( D2X( LENGTH( Shadow.i.longname ), 4 ))
     77               rc = SysPutEA( fullfilename, '.LONGNAME', X2C('FDFF') || REVERSE( lenbytes ) || Shadow.i.longname )
     78               if rc \= 0 then
     79                  do
     80                     call lineout error_log, 'Error in setting .LONGNAME EA: 'rc
     81                     errors = errors + 1
     82                  end
     83
     84               p = lastpos('\', Shadow.i.filename)
     85               if p > 0 then
     86                  shadowidname = substr(Shadow.i.filename, p + 1)
     87               else
     88                  shadowidname = Shadow.i.filename
     89               rc = SysCreateObject( 'WPShadow', Shadow.i.longname, Shadow.i.folderid , 'SHADOWID='fullfilename';OBJECTID=<FM3_Shadow_'shadowidname'>;', 'R')
     90               if rc \= 1 then
     91                  do
     92                     call lineout error_log, 'Unable to create shadow object for :'Shadow.i.filename
     93                     errors = errors + 1
     94                  end
    8995            end
    9096      end
    9197end
     98if errors > 0 then
     99   do
     100      call lineout error_log, errors 'errors encountered.'
     101      call stream error_log, 'c', 'close'
     102   end
    92103
Note: See TracChangeset for help on using the changeset viewer.