// The Hammer built-in compiler for DataFlex // Use VDFCompCtl.pkg Class cTHCompiler is a cComVDFCompiler Procedure Construct_Object Forward Send Construct_Object Property Integer piCompilingMode 0 //Set peAutoCreate to acAutoCreate End_Procedure Procedure AddPath String ByRef sMakePath String sPath If (sMakePath="") Move sPath to sMakePath Else Move (sMakePath + ';' + sPath) to sMakePath End_Procedure Function CompileMakePath String sVDFRoot Boolean bPrecompile Returns String String sMakePath sPath If (not(bPrecompile)) Begin Get CurrentAppSrcPath of ghoWorkSpaceHandlerEx to sPath Send AddPath (&sMakePath) sPath Get CurrentDdSrcPath of ghoWorkSpaceHandlerEx to sPath Send AddPath (&sMakePath) sPath Get CurrentDataPath of ghoWorkSpaceHandlerEx to sPath Send AddPath (&sMakePath) sPath Get CurrentBitmapPath of ghoWorkSpaceHandlerEx to sPath Send AddPath (&sMakePath) sPath Get LibraryAppSrcPaths of (oLibraries(ghoWorkSpaceHandlerEx)) to sPath If (sPath<>"") Send AddPath (&sMakePath) sPath End Send AddPath (&sMakePath) (sVDFRoot + "Bin") Send AddPath (&sMakePath) (sVDFRoot + "Lib") Send AddPath (&sMakePath) (sVDFRoot + "Usr") Send AddPath (&sMakePath) (sVDFRoot + "Pkg") Send AddPath (&sMakePath) (sVDFRoot + "Bitmaps") Function_Return sMakePath End_Function Function CompileTarget String sSource Returns String String sTarget sFile Move (FileFromPath(sSource)) to sFile If (Right(Uppercase(sFile), 4)=".SRC") ; Move (Left(sFile, Length(sFile)-4)+".exe") to sFile Get CurrentProgramPath of ghoWorkSpaceHandlerEx to sTarget If (Right(sTarget,1)<>'\') Move (sTarget + '\') to sTarget Function_Return (sTarget + sFile) End_Function Procedure PrepareToCompile Boolean bPrecompile String sSource Handle hoClient String sVdfRoot sWrapper sMakePath Get Client_Id to hoClient Get psVdfRootDir of ghoWorkSpaceHandlerEx to sVdfRoot If (Right(sVdfRoot,1)<>'\') Move (sVdfRoot + '\') to sVdfRoot Move (sVdfRoot + "Bin\" + "DFC.exe") to sWrapper If (bPrecompile) Begin // If not a System Package, then set App Make Path and System otherwise If (not(Uppercase(sSource) contains Uppercase(sVdfRoot))) ; Move 0 to bPrecompile End Get CompileMakePath sVDFRoot bPrecompile to sMakePath Set ComCompiler to sWrapper Set ComMakePath to sMakePath Set piCompilingMode to True If (piDisplayWatchAutomatic(ghoEditorProperties)) ; Send PAWindowErrorListONOFF to hoClient True End_Procedure Procedure Compile String sSource Number nVer String sTarget sDesc If (piCompilingMode(Self)) Procedure_Return Send PrepareToCompile (False) sSource Get CompileTarget sSource to sTarget Move (_T("Compiling", 465)) to sDesc If ghoCompilerInfo ; Send mStart to ghoCompilerInfo ("----" * sDesc * sSource * "----") Get fnCurrentVdfVersion of ghoWorkSpaceHandlerEx to nVer // 70=VDF7, 82=VDF8.2 If (nVer<191) Begin Send ComCompile sSource sTarget True End Else Begin Send ComCompile191 sSource sTarget True True End End_Procedure Procedure PreCompile String sPackage Number nVer String sDesc If (piCompilingMode(Self)) Procedure_Return Send PrepareToCompile (True) sPackage Move (_T("Pre-Compiling", 467)) to sDesc If ghoCompilerInfo ; Send mStart to ghoCompilerInfo ("----" * sDesc * sPackage * "----") Get fnCurrentVdfVersion of ghoWorkSpaceHandlerEx to nVer // 70=VDF7, 82=VDF8.2 If (nVer<191) Begin Send ComPrecompile sPackage True End Else Begin Send ComPrecompile191 sPackage True True End End_Procedure Procedure OnComEndCompile Boolean llcompileSuccessful Handle hoClient String sDesc Get Client_Id to hoClient Set piCompilingMode to False Move (_T("Compile Finished", 466)) to sDesc If ghoCompilerInfo ; Send mFinish to ghoCompilerInfo ("----" * sDesc * "----") If hoClient Send CACompleteCompileAction to hoClient End_Procedure Procedure OnComCompileMessage String lltext If ghoCompilerInfo ; Send AddMessage to ghoCompilerInfo llText 1 End_Procedure Procedure OnComCompileWarning String lltext If ghoCompilerInfo ; Send AddMessage to ghoCompilerInfo llText 2 End_Procedure Procedure OnComCompileError String lltext If ghoCompilerInfo ; Send AddMessage to ghoCompilerInfo llText 3 End_Procedure Procedure OnComCriticalError String lltext If ghoCompilerInfo ; Send AddMessage to ghoCompilerInfo llText 3 End_Procedure End_Class Function BuiltInCompiler Returns Handle Handle hoCompiler Integer iCompiler String sVersion Number nVersion tTHCompiler[] THCompilers // External compiler only will switch off built-in compiler feature If (pbExtCompilerOnly(ghoEditorProperties)) Function_Return 0 // Get psVDFVersion of ghoWorkSpaceHandlerEx to sVersion Get StringVdfVersionToNum Of ghoWorkspaceHandlerEx sVersion To nVersion #IFDEF IS$WIN64 If (nVersion < 200) Function_Return 0 // the built-in compiler for DF20.0 is the only 64 bit one #ELSE If (nVersion >= 200) Function_Return 0 // no built-in compiler for DF20.0 when 32 bit (I think, check it) #ENDIF Get THFindBuiltInCompiler sVersion to iCompiler If (iCompiler>=0) Begin Get pTHCompilers of ghoApplication To THCompilers If (THCompilers[iCompiler].hoCompiler) Begin Move THCompilers[iCompiler].hoCompiler to hoCompiler End Else Begin Get Create (RefClass(cTHCompiler)) to hoCompiler If (hoCompiler) Begin Set psProgID of hoCompiler to THCompilers[iCompiler].sProgID //Set psEventId of hoCompiler to THCompilers[iCompiler].sEventId Send CreateComObject of hoCompiler // Cache object for re-using If (IsComObjectCreated(hoCompiler)) Begin Move hoCompiler to THCompilers[iCompiler].hoCompiler End Else Begin Send Destroy of hoCompiler // If can't create compiler activex object then destroy // the object as it will leak memory otherwise End // This method is called from a timer! Set pTHCompilers of ghoApplication To THCompilers End End End Function_Return hoCompiler End_Function