|
|
| HOpen(...)-ing the HyperFileSQL Files One of the first things you have to do in project which uses HyperFileSQL Classic files is to HOpen(..) them and look for the results. This seems to be a straightforward process, no need to invest a lot of care. Usually, beginners will start a program using HCreationIfNotFound(“*”) in the project code. This creates all non-existing files in the project’s \exe directory or opens them in case they already exist. HCreationIfNotFound(“*”) is simple to us but it has its downsides. First of all, it is SLOW. Opening 100 HFSQL-files using HCreationIfNotFound(“*”) will be noticed a lot. Next, it’s hard to catch errors and identify a ‘bad’ file in the process. So, WinDev users tend to take the next step by applying HCreationIfNotFound(..) on a file by file basis while looking for errors that might happen during execution of HCreationIfNotFound(..). A part of the project code (generated by WinDev RAD) might look like this: //----------------- R A D W i n D e v 8---------------// Files creationIF NOT HCreationIfNotFound(THEMA) THEN Info("The File could not be opened / created : THEMA",HErrorInfo())IF NOT HCreationIfNotFound(RUECKEN) THEN Info("The File could not be opened / created : RUECKEN",HErrorInfo())IF NOT HCreationIfNotFound(HOEHE) THEN Info("The File could not be opened / created : HOEHE",HErrorInfo()) Still, the process of of opening the HFSQL-Files is slow but improved by the ability to identify the file name whenever an error happens. Writing the code like shown by hand is not so easy for 100 files and adding / deleting files to / from the analysis will inevitably force you to revisit the project code, adding / deleting lines of code. The WinDev command HListFile(..) lets you enumerate the files of the analysis .. MyString = HListFile("","",hLstNormal)+CR // Do not forget the +CR, it’s needed to make StringCount workFOR MyI = 1 TO StringCount(MyString,CR) My_File = ExtractString(MyString,MyI,CR) IF NOT HCreationIfNotFound(My_File) THEN Info("The File could not be opened / created : "+My_File,HErrorInfo())END Still, HCreationIfNotFound(..) is really slow. To repair that, let’s avoid it at all and find a workaround: We can test all files for existence first. If any of the files doesn’t exist, we would create it by HCreation(..). After that, we do an HOpen(..) for all of the files in the analysis. That’s really fast and HOpen(..) is the *only* way to analyse the files of an application for a range of error conditions. No other command can do that! MyString = HListFile("","",hLstNormal)+CRMyX = StringCount(MyString,CR)FOR MyI = 1 TO MyX My_File = ExtractString(MyString,MyI,CR) IF NOT HFileExist(My_File) THEN IF NOT HCreation(My_File) THEN Info("The File could not be created : "+My_File,HErrorInfo()) ENDEND FOR MyI = 1 TO MyX My_File = ExtractString(MyString,MyI,CR) WHEN EXCEPTION IN HOpen(My_File) DO // There’s a problem IF HError() = 70021 OR HError() = 70052 THEN HIndex(My_File,hNdxSilent) IF HError() = 70016 THEN Info("Datei: "+My_File,"Error 70016 happened !") // .. expand checking here .. ENDEND The Generation NumberAll or let’s say most of the possible errors can be handled if you invest some lines of code into the loops shown above. However, there’s one exception - 70016. 70016 tells us that the physical file’s generation number doesn’t fit to the analysis! If you remember, whenever you’re generating an analysis the generation number of a file in the analysis is incremented by 1 - if its structure was changed. So, simply said 70016 states that the internal generation number is not equal to the generation number of the physical file. There is a difference in structure between the file description (= analysis) and the file. Any difference in structure can be fixed by running WDMODFIC.EXE, the WD-tool which will restructure a physical file to match the structure as it is described in the analysis. Of course, if the generation number of the analysis is lower than that of the physical file, we’re losing the game! This means that the analysis is older than the file! We can can run WDMODFIC forever - error 70016 will still be there. And there’s no way to inform the user about the real problem: they’re using an old software with a possibly up-to-date file set. This happens at a customer site when some problems appear and a ‘clever’ user believes that there’s a problem with the program and does an update using an old program-CD. In the past, there were some suggestions on the forum to detect this condition. Hard to implement. The most simple solution would be to have an additional file property which returns the generation number of the file from the analysis like: IntGenNum = CUSTOMERFILE..InternalGenerationNumber Just in case we’d have such a command on receiving a 70016 we’d be able to detect whether the internal generation number is higher or lower than the file’s generation number - and act accordingly! This is still impossible and we’re waiting for such a command since WinDev 5.5 Please note: There is a workaround to retrieve the internal generation number! |
|
|
|