//TH-Header //***************************************************************************************** // Copyright (c) 2001 Udo Haemel // All rights reserved. // If you want to use this source in your applications conatct: // $FileName : cFileOperations.pkg // $ProjectName : The Hammer // $Author : Udo Haemel // $Created : 26.06.2001 20:05 // // Contents: // Basic Class for any Operations on DF-Tables // Global Definition of constants for DF-Tables // Global access on DF-Tables by Tablename //***************************************************************************************** //TH-RevisionStart // 26.06.2001 20:30 Trap wrong Filenumbers in pOpen Uh // in class "cFileOperations". // 26.06.2001 20:30 Added symbols for min/max File/Index Uh // ___ANY BETTER SUGGESTIONS?___ //TH-RevisionEnd // For use in old DF 3.x #IFDEF Self #ELSE #Replace Self CURRENT_OBJECT #ENDIF #IF (!@>69) #Replace __DF_FIRST_FILE__ |CI1 #Replace __DF_LAST_FILE__ |CI4095 #Replace __DF_FIRST_INDEX__ |CI1 #Replace __DF_LAST_INDEX__ |CI16 #ELSE #Replace __DF_FIRST_FILE__ |CI1 #Replace __DF_LAST_FILE__ |CI255 #Replace __DF_FIRST_INDEX__ |CI1 #Replace __DF_LAST_INDEX__ |CI16 #ENDIF // Delivers the filenumber of the given filename in the current filelist. Function IdentifyFile GLOBAL String hFileName Returns Integer Integer iFile String sRootname Move (Uppercase(Trim(hFileName))) to hFileName Move 0 to iFile Repeat Get_Attribute Df_File_Next_Used Of iFile To iFile If iFile Gt 0 Begin Get_Attribute Df_File_Logical_Name Of iFile To sRootname If (hFileName=(Uppercase(Trim(sRootname)))) Function_Return iFile End Until iFile Eq 0 Function_Return -1 End_Function Class cFileOperations Is An ARRAY Procedure Construct_Object Forward Send Construct_Object End_Procedure // Construct_Object // Try to open the given file. If // it fails it returns 0. If file // was open, it returns 1 otherwise 2 // Function pOpen Integer iFile ; Returns Integer Integer bOpen If (iFile >= __DF_FIRST_FILE__ And iFile <= __DF_LAST_FILE__) Begin Get_Attribute DF_FILE_OPENED Of iFile To bOpen // if not already opend, try to open file // ignore-trap-trick from Wil van Antwerpen // If (Not(bOpen)) Begin //@ RRS Send Load_DBDrivers iFile // changed the ignore_error ## to ignore_all, since it could happen, that you // get other error messages (i.e. pervasive). after that, you fly out (quite nice // if you don't save your code every 5 minutes... -( // 17.10.01 Bernhard If (not(IsDebuggerPresent())) Send Ignore_all to Error_Info_Object //@ RRS Open iFile If (found) Begin Move 2 To bOpen End If (not(IsDebuggerPresent())) Send Trap_All to Error_Info_Object //@ RRS End End Function_Return bOpen End_Function Procedure pClose Integer iFile ; Integer iState If (iState = 2) Begin Close iFile End End_Procedure //@ RRS Function DriverIndex String lsDriver Returns Integer String lsCurrentDriver Integer liDriver Integer liNumDrivers Get_Attribute DF_NUMBER_DRIVERS to liNumDrivers For liDriver from 1 to liNumDrivers Get_Attribute DF_DRIVER_NAME of liDriver to lsCurrentDriver If (Uppercase(lsDriver) = Uppercase(lsCurrentDriver)) Function_Return liDriver Loop Function_Return 0 End_Function // DriverIndex //@ RRS Function DriverLoad String lsDriver Returns Integer Integer liDriver String sDrvFileName Get DriverIndex lsDriver to liDriver If (liDriver=0) Begin Get_File_Path (lsDriver+".dll") to sDrvFileName If (sDrvFileName="") Move lsDriver to sDrvFileName If (sDrvFileName<>"") Begin Load_Driver sDrvFileName If (not(Err)) Get DriverIndex lsDriver to liDriver End End Function_Return liDriver End_Function //@ RRS Procedure Load_DBDrivers Integer iFile String sRootName sDriverName Integer iRet Move 0 to iRet Get_Attribute DF_FILE_ROOT_NAME of iFile to sRootName If (Pos(":",sRootName)) Begin Move (Uppercase(Left(sRootName,Pos(":",sRootName)-1))) to sDriverName If (sDriverName<>"") Get DriverLoad sDriverName to iRet End End_Procedure Function Request_Open_File Integer hTable Returns Boolean Boolean bOpened Get_Attribute DF_FILE_OPENED of hTable to bOpened If (bOpened=False) Send Load_DBDrivers hTable Move 0 to LastErr Send Ignore_all to Error_Info_Object If (not(bOpened)) Open hTable Send Trap_All to Error_Info_Object Get_Attribute DF_FILE_OPENED of hTable to bOpened Function_Return bOpened End_Function End_Class // cFileOperations