Module VersionControl.pkg

     1//************************************************************************
     2//
     3// Confidential Trade Secret.
     4// Copyright 1998 Data Access Corporation, Miami FL, USA
     5// All Rights reserved
     6// DataFlex is a registered trademark of Data Access Corporation.
     7//
     8//****************************************************************************//
     9//                                                                            //
    10// $File name  : VersionControl.pkg                                           //
    11// $File title : Internal control for version checking                        //
    12// Notice      :                                                              //
    13// $Author(s)  : John Tuohy                                                   //
    14//                                                                            //
    15// $Rev History                                                               //
    16//                                                                            //
    17// JT  11/9/98 Created                                                        //                                                                           //
    18//****************************************************************************//
    19
    20//This is an internal pakcage and is USEd within dfbase.pkg
    21//
    22//This contains two compiler commands and one Runtime command:
    23//Validate_Fmac Ver# Rev# Build#
    24//    If version number in fmac is not equal to or greater than the value
    25//    passed here, a compile error is declared. This command is invoked within this
    26//    package. The Version numbers are stored in fmac as :
    27//          FMAC_Version FMAC_Revision FMAC_Build
    28//    The required version numbers are defined in dfbase.pkg as:
    29//          Required_FMAC_Version Required_FMAC_Revision Required_FMAC_Build
    30
    31
    32//Validate_Packages Ver# Rev# Build#
    33//    If version number of package is not equal to or greater than the value
    34//    passed here, a compile error is declared. The package number is defined in
    35//    dfbase.pkg as:
    36//          PKG_Version PKG_Revision PKG_Build
    37//    This is not invoked automatically but may be added to a developer's
    38//    program. You must define and pass the minimum required version numbers.
    39
    40//Send ValidateVersion
    41//   This is called at runtime (and is called by this package). It insures that the
    42//   runtime version (which is stored in dfrun.dll) is equal to or greater than the
    43//   minimum required runtime version. The minimum is defined in dfbase.pkg as:
    44//        Required_RT_Version Required_RT_Revision Required_RT_Build
    45Use LanguageText.pkg
    46Use GlobalFunctionsProcedures.pkg
    47
    48// Validate fmac version against a passed minumum
    49#COMMAND Validate_Fmac R R R    // version, revision, build
    50  #IFDEF FMAC_VERSION
    51    #IF (FMAC_Version<!1)
    52      #ERROR DFERR_WRONG_REVISION FMAC Version Mismatch
    53    #ELSE
    54      #IF (FMAC_Version = !1)
    55        #IF (FMAC_Revision<!2)
    56          #ERROR DFERR_WRONG_REVISION FMAC Version Mismatch
    57        #ELSE
    58          #IF (FMAC_Revision = !2)
    59            #IF (FMAC_Build<!3)
    60              #ERROR DFERR_WRONG_REVISION FMAC Version Mismatch
    61            #ENDIF
    62          #ENDIF
    63        #ENDIF
    64      #ENDIF
    65    #ENDIF
    66  #ELSE  // if not defined, it is an old version
    67    #ERROR DFERR_WRONG_REVISION FMAC Version Mismatch
    68  #ENDIF
    69#ENDCOMMAND
    70
    71// Validate fmac version against a passed minumum
    72#COMMAND Validate_Packages R R R    // version, revision, build
    73  #IFDEF PKG_VERSION
    74    #IF (PKG_Version<!1)
    75      #ERROR DFERR_WRONG_REVISION PKG Version Mismatch
    76    #ELSE
    77      #IF (PKG_Version = !1)
    78        #IF (PKG_Revision<!2)
    79          #ERROR DFERR_WRONG_REVISION PKG Version Mismatch
    80        #ELSE
    81          #IF (PKG_Revision = !2)
    82            #IF (PKG_Build<!3)
    83              #ERROR DFERR_WRONG_REVISION PKG Version Mismatch
    84            #ENDIF
    85          #ENDIF
    86        #ENDIF
    87      #ENDIF
    88    #ENDIF
    89  #ELSE  // if not defined, it is an old version
    90    #ERROR DFERR_WRONG_REVISION PKG Version Mismatch
    91  #ENDIF
    92#ENDCOMMAND
    93
    94{ Visibility=Private }
    95Procedure gValidate$Version Global integer iReqVersion integer iReqRevision integer iReqBuild
    96    Integer iVersion iRevision iBuild
    97    Version_Information iVersion iRevision iBuild
    98    //
    99    If (iVersion < iReqVersion OR ;
   100        (iVersion=iReqVersion AND iRevision<iReqRevision) OR ;
   101        (iVersion=iReqVersion AND iRevision=iReqRevision AND iBuild<iReqBuild) ) Begin
   102
   103           Error DFERR_WRONG_REVISION (SFormat(C_$RuntimePackageMismatch, iVersion, iRevision, iBuild, iReqVersion, iReqRevision, iReqBuild))
   104
   105           Abort
   106    End
   107End_Procedure
   108
   109// This will gen compiler error if fmac is too old
   110Validate_Fmac Required_FMAC_Version Required_FMAC_Revision Required_FMAC_Build
   111// This generates a runtime error packages are old
   112Send gValidate$Version Required_RT_Version Required_RT_Revision Required_RT_Build
   113