CheckSPFXP Method
Class: _DBC_Check
Expand/Collapse source code of procedure CheckSPFXP Source Code
      LPARAMETERS lcAlias,loInfo
      * lcAlias - Alias of opened DBC
      * loInfo  - Info object


      * backup SET DEFA
      * set DBC path as SET DEFA
      * save SP as PRG and recompile it
      * Get SP FXP and compare it with recompiled source code

      LOCAL lcOldDEFA,lcSC,lcFXP,lcTMP,lcFRXPN,luCatch
      lcOldDEFA=SET("DEFA")+CURDIR()

      SET DEFAULT TO (JUSTPATH(DBF(lcAlias))+"\")
      * Get Stored Procedure
      =loDBC.GetSP(lcAlias,_DBC_SP_TSource,@lcSC)
      =loDBC.GetSP(lcAlias,_DBC_SP_TFXP,@lcFXP)
      lcTMP=SYS(2023)+"\"+SYS(2015)+".prg"
      loInfo.SPFXP=_DBC_SP_CheckFXP_OK

      luCatch=m.This.SetCatch(.T.)
      =STRTOFILE(lcSC,lcTMP)
      IF This.nErr#0
         loInfo.SPFXP=_DBC_SP_CheckFXP_CantSavePRG
      ENDIF
      IF This.nErr=0
         =m.This.SetCatch(.T.)
         COMPILE (lcTMP) 
         IF This.nErr#0
            loInfo.SPFXP=_DBC_SP_CheckFXP_CantCompilePRG
         ENDIF
      ENDIF     

      IF This.nErr=0
         =m.This.SetCatch(.T.)
         lcFXPN=FILETOSTR(FORCEEXT(lcTMP,"fxp"))
         IF This.nErr#0
            loInfo.SPFXP=_DBC_SP_CheckFXP_CantReadFXP
         ENDIF
      ENDIF     

      IF This.nErr=0
         loInfo.SPFXP = IIF(lcFXP==lcFXPN,_DBC_SP_CheckFXP_OK,_DBC_SP_CheckFXP_Failed) && Stored procedures FXP status
         IF FILE(FORCEEXT(lcTMP,"err"))
            =m.This.SetCatch(.T.)
            loInfo.SPFXPResult = FILETOSTR(FORCEEXT(lcTMP,"err")) && Stored procedures Error result
            IF This.nErr#0
               loInfo.SPFXP=_DBC_SP_CheckFXP_CantReadErr
            ENDIF
         ENDIF
      ENDIF

      DELETE FILE (lcTMP)
      DELETE FILE (FORCEEXT(lcTMP,"fxp"))
      DELETE FILE (FORCEEXT(lcTMP,"err"))
      SET DEFAULT TO (lcOldDEFA)
      =m.This.SetCatch(luCatch)