` Comment on an Icetips Article
Icetips - Templates, Tools & Utilities for Clarion Developers

Templates, Tools and Utilities
for Clarion Developers

Add a comment to an Icetips Article

Please add your comments to this article. Please note that you must provide both a name and a valid email address in order for us to publish your comment. Comments are moderated and are not visible until they have been approved. Spam is never approved!

Your Name:  
Email:  
Header text/Subject:  

Please enter your comment in the box below:

Back to article list   Search Articles     Add Comment     Printer friendly     Direct link  

ABC: Autoincrement on alias files
1998-11-02 -- Jim Gambon
 
Newsgroups: topspeed.products.c5ee.bugs I have come across a bug that was in C4b and is still in C5EE. This bug concerns auto incrementing keys on alias files. The bug is in the FileManager.PrimeRecord method. The method tests to see if the priming is happening to an alias file. If it is, it primes the "real" file instead (as it should, so as to use any over-ridden field priming methods in the "real" file's filemanager.) But, instead of correctly swapping file buffers and auto incremented numbers back to the alias file, it tends to lose its place and run time errors may occur - especially if the "real" file and the alias file are needing to be updated from the same browse or form. Andrew Guidroz came up with a technique in C4b to solve this problem. I enhanced it slightly and it works well for what I need. I discovered that C5EE did not implement Andrew's bug fix when I tried to place two combo lists on the same form, one from a "real" file and one from an alias of the same file. The file had two keys - the auto incrementing key and a unique name key. The alias file would get a "duplicate key" error on the unique name key if the "real" file buffer was not empty. I tracked the error back to the same Alias file buffering problem in the PrimeRecord method that Andrew helped me fix in C4b months ago. The following is from the C5EE abfile.clw - Filemanager.PrimeRecord method: ELSE BufferHandle=SELF.AliasedFile.SaveBuffer() Result=SELF.AliasedFile.PrimeRecord(SC) IF ~Result SELF.Buffer=SELF.AliasedFile.Buffer END SELF.AliasedFile.RestoreBuffer(BufferHandle) RETURN Result END The following is the same section with the bug fix (commented). ELSE BufferHandle=SELF.AliasedFile.SaveBuffer() ! Start of Bug Fix 11/11/1998 - Part 1 ! The following line was added by JMG on 11/11/1998 to correct a ! bug caused by not clearing the file buffer when autoincrememting ! an Aliased file. SELF.AliasedFile.Buffer = SELF.Buffer ! End of Fix - Part 1 Result=SELF.AliasedFile.PrimeRecord(SC) IF ~Result SELF.Buffer=SELF.AliasedFile.Buffer ! Start of Bug Fix 11/10/1998 - Part 2 ! The following five line were added by JMG for working around a ! bug in C4b and C5EE (11/11/1998) concerning AutoInc keys in ALIAS files. ! This fix devised by Andrew Guidroz II. ! First get the correct position in the ALIASed file Self.TryReget(Self.AliasedFile.Position()) ! Set the AutoInc flags Properly Self.Info.AutoIncDone = Self.AliasedFile.Info.AutoIncDone Self.AliasedFile.Info.AutoIncDone = 0 ! Update the Autoinc Flag on both files PUT(Self.Info) PUT(Self.AliasedFile.Info) ! End of Andrew's revisions ! End of Fix - Part 2 END SELF.AliasedFile.RestoreBuffer(BufferHandle) RETURN Result END If you run across this bug I hope this helps you work around it. Jim P.S. Thanks again Andrew for this bug fix.


Today is November 21, 2024, 6:32 am
This article has been viewed 35398 times.
Google search has resulted in 26 hits on this article since January 25, 2004.



Back to article list   Search Articles   Add Comment   Printer friendly

Login

User Name:

Password: