|
|
| Workaround: How to get the Analysis-Internal File Generation Numbers Overview: Currently, there’s no WinDev-command for retrieving the Internal Generation Number of a file description from the analysis of a project (see discussion). In case of file error 70016, the comparison between the Internal Generation Number and the actual generation number of a file could reveal whether the data file is too old or too new in regards to the current state of the project’s analysis. Workaround: Mr Patrick Philipot from PC Soft Technical Support suggested the principle of a workaround for this problem: Change directory to a temporary directory - create a file there with the same name - read the temp-file’s Generation Number - delete the temp-file - change directory back to the original working directory - read Generation Number from work file and compare! Of course, the actual solution is a bit more complex, but the principle is correct! Below you can see the code necessary to open a set of files described in the analysis of a project. For the project, there’s a users-choice to either run it in HFSQL C/S or HFSQL Classic. Timing: on the test-computer (AMD Athlon II+ / 5200 MHz) 45 files take 0.16 seconds to open without retrieving the Generation Number and takes 0.42 seconds with retrieving the analysis’ generation Number. I could imagine some improvements to the code. Some variables / messages are in German but shouldn’t prevent you from understanding the code .. // Open data files of the projectMyString3 = "" // MyString3 will contain the error-information for the user// 1 - Is a data file missing? If so, let’s create it!ErgebnisString = HListFile("","",hLstNormal)+CRFOR MyI = 1 TO StringCount(ErgebnisString,CR) My_File = ExtractString(ErgebnisString,MyI,CR) IF NOT HFileExist(My_File) THEN HCreation(My_File) MyString3 += "Info: File "+My_File+" was missing and has been generated !"+CR ENDEND // In HF Classic we have to explicitely create the TEMP-directory while in HFSQL C/S the command HChangeDir() will automatically create the \TEMP directory!IF MyHFCSorHFClassic = "HFClassic" THEN IF NOT fDirectoryExist(CompleteDir(NoSpace(MyPathToHFClassic))+"TEMP") THEN fMakeDir(CompleteDir(NoSpace(MyPathToHFClassic))+"TEMP") ENDEND // Open the data files while observing their errors, in case of a 70016 error we will inspect / compare generation numbers ErgebnisString = HListFile("","",hLstNormal)+CR FOR MyI = 1 TO StringCount(ErgebnisString,CR) My_File = ExtractString(ErgebnisString,MyI,CR) // Retrieve Internal Generation Number from aanalysis IF MyHFCSorHFClassic = "HFCS" THEN // HF C/S HChangeDir(My_File,".\TEMP") HCreation(My_File,hNoLink) IntGenNumber = {My_File,indFile}..GenerationNumber HChangeDir(My_File,"") ELSE // HF Classic HChangeDir(My_File,CompleteDir(NoSpace(MyPathToHFClassic))+"TEMP") HCreation(My_File,hNoLink) IntGenNumber = {My_File,indFile}..GenerationNumber HChangeDir(My_File,CompleteDir(NoSpace(MyPathToHFClassic))) END WHEN EXCEPTION IN HOpen(My_File) DO // We come here if the file got a problem on HOpen() SWITCH HError() CASE 70021, 70052 HIndex(My_File,hNdxSilent) MyString3 += "Corrupted Index "+HError()+" in File "+My_File+" : file has been re-indexed !"+CR CASE 70003 MyString3 += "Error "+HError()+" in File "+My_File+" : File was missing !"+CR HCreation(My_File) CASE 70016 HCheckStructure(My_File,hNoCheck) ActGenNumber = {My_File,indFile}..GenerationNumber IF ActGenNumber > IntGenNumber THEN RunUPDATE = True Error("File :"+My_File, "Error 70016 appeared","Programm Gen# "+IntGenNumber,"File Gen# "+ActGenNumber,"Explanation:","You’re using an older program together with newer files!","You have to UPDATE the program to its newest revision level !") MyString3 += "ERROR "+HError()+" in File "+My_File+" UPDATE needed!"+CR+"Your program xyz must be updated to its newest revision level !"+CR ELSE RunWDMODFIC = True Error("File: "+My_File,"Error 70016 appeared !","You have to restructure the data files of program xyz by using WDMODFIC !") MyString3 += "ERROR 70016 in File "+My_File+"Restructure Data Files using WDMODFIC !" + CR END HCheckStructure(My_File,hIdentical) OTHER CASE MyString3 += "ERROR "+HError()+" appeared in File "+My_File+CR END ENDEND IF MyString3 <> "" THEN Error("Errors as shown happened while opening the data files of the program xyz:",MyString3)END IF RunWDMODFIC = True THEN MyString3 = "WDModfic.exe -wizard -report -error /WDD="+Charact(34)+CompleteDir(fExeDir())+"BackPrima.WDD"+Charact(34)+" /US" ExeRun(MyString3,exeMaximize,exeWait) EndProgram()END IF RunUPDATE = True THEN EndProgram("Visit our web site www.ourwebsite.com and download / install the","newest version of program xyz !")END IF MyString3 <> "" THEN EndProgram("During the opening priocess of the data files of program xyz one or more errors have been experienced!","At least, you simply have to restart the program xyz !","If errors persist, you can try to repair them by using the","HyperFileSQL Control Center. If this doesn’t help, you will have to restore a former backup of the data !")END |
|
|
|