Info regarding HCreationIfNotFound with hDelayedOpening

Startbeitrag von Frans am 17.05.2013 17:01

Hello to you all,

I want to share a testing result regarding HCreationIfNotFound with hDelayedOpening because there was a thread about HCreationIfNotFound .

My HFCS database has about 90 files, I use HCreationIfNotFound . No problem.
Now I have a connection via a Wan. Of course this takes more time then on a Lan.
Opening all the files takes about 2,7 seconds.
I thought that opening with hDelayedOpening could spare some time. Not true.
It took 5,8 seconds. More then double the time.

Antworten:

Hello Frans

It would be interesting to see what the timing was if you used the project option to set the HcreationIfNotFound as I believe that it only creates files as the app calls for them so there should be no initial delay. All of my experience has been with local data, so there may be other factors coming in to play when the data is remote as your is.

Regards
Al

von Al - am 17.05.2013 17:03
Hello Al,

On your proposel I made an extra test.

Deleting all the HcreationIfNotFound: 2,7 seconds is now 0.3 seconds (there is some code left). With project option HcreationIfNotFound on: Also 0.3 seconds.

von Frans - am 17.05.2013 17:19
Hello Frans

Thank you for doing that test. It means that the project option is the best way to go as it only creates files as they are required and not all at once in the beginning and doesn't test for them all at project opening.

Regards
Al

von Al - am 17.05.2013 22:50
Hi friends,

quite some time ago, I've been in the HCreationIfNotFound(..)-business too and found it too slow for everyday's opening of files. Too make it clear: most times the program is opened, there is no need to create any files at all. For detection whether a file is missing (= needs creation) a simple HOpen(..) and a subsequent error-analysis is sufficient. HOpen(..) is much, much faster than HCreationIfNotFound(..) and if a file is not there, HCreation(..) will be there to create the specific file. As a result I refrained from using HCreationIfNotFound(..).

Below there's an example from one of my projects. Unfortunately, the codes looks a bit more complicated and the comments are in German. Imho, the most important question while opening the files is not whether the file exists or not. The important question is: will it work with the program, is it of the version we need, does it need a restructuring or is its version newer than the program's version (= an unusable data set)?


// Open der Dateien mit spezieller Beachtung des Index und der Struktur
ErgebnisString = HListFile("","",hLstNormal)+CR

FOR MyI = 1 TO StringCount(ErgebnisString,CR)
My_File = ExtractString(ErgebnisString,MyI,CR)
// Retrieve Internal Generation Number from analysis
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
// Diese Datei hat ein Problem
// MyString3 += " Fehler: "+NumToString(HError(hErrCurrent))
SWITCH HError()
CASE 70021, 70052
HIndex(My_File,hNdxSilent)
MyString3 += "Index-Fehler "+HError()+" in Datei "+My_File+" : Datei wurde re-indiziert !"+CR

CASE 70003
MyString3 += "Schwerer Fehler "+HError()+" in Datei "+My_File+" : Datei fehlte !"+CR
HCreation(My_File)

CASE 70016
HCheckStructure(My_File,hNoCheck)
ActGenNumber = {My_File,indFile}..GenerationNumber
IF ActGenNumber > IntGenNumber THEN
RunUPDATE = True
Error("Datei :"+My_File, "Fehler 70016 aufgetreten","Programm Gen# "+IntGenNumber,"Datei Gen# "+ActGenNumber,"Erklärung:","Sie verwenden ein älteres Programm zusammen mit neueren Dateien!","Sie müssen das Programm auf den neuesten Stand updaten !")
MyString3 += "Schwerer Fehler "+HError()+" in Datei "+My_File+" UPDATE erforderlich!"+CR+"Ihr Programm Bäckerei Prima! muß per UPDATE aufden neuesten Stand gebracht werden !"+CR
ELSE
RunWDMODFIC = True
Error("Datei: "+My_File,"Fehler 70016 aufgetreten !","Sie müssen die Dateien von Bäckerei Prima! mittels WDMODFIC restrukturieren!")
MyString3 += "Schwerer Fehler 70016 in Datei "+My_File+"aufgetreten : Dateien mit WDMODFIC restrukturieren!" + CR
END
HCheckStructure(My_File,hIdentical)

OTHER CASE
MyString3 += "Fehler "+HError()+" mit Datei "+My_File+" aufgetreten !"+CR

END
END
END



Kind regards,
Guenter

von GuenterP - am 18.05.2013 04:44
Hi Guenter,

This is interesting because we implemented something almost similar to your code. In fact we also check for any password error (and subsequent retructuring). This solution works very well and spped is acceptable. When restructuring is required (or any other process) we automatically open a progress window to show that if the application is slow to start it's because files are being updated.

The difference is that we do not care about checking the generaion number since it's not necessary. (You can directly do a HModifyStructure(hmsNormal) and check if there is an error 70227 - file generation number more recent than the one from analysis - then safely ignore and open the file in compatible mode.) It is more strait forward: directly change HCheckStructure() for identical comparison, then try to open the file, manage any error, close the file, set back comparison mode to compatible; if any error has been fixed, try again in compatible mode. We also have resiliance level to undefined errors while opening files.

Best regards,
Alexandre Leclerc

von Alexandre Leclerc - am 21.05.2013 12:56
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.