Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB General » View Thread |
Messages 1 to 8 of 8 total |
Recno replacement |
Tue, Jul 22 2008 12:52 PM | Permanent Link |
"Eduardo [HPro]" | Tim
I know Recno property has not the same funcionality used in DBISAM. But I have a lot of code like below: var nRec: Integer; begin nRec := Table.Recno; // Do some record pointer changes Table.Recno := nRec; end; I think I have to change to use BookMarks (without index change) but TBookmark is a Pointer and I have an inherited TEDBTable and I want to create a special property RecordId or something else to act like Recno in DBISAM. There is a manner to convert a Pointer type to an integer ? If it could be possible I will deal internally (in the inherited component) using Bookmarks and convert to an integer to return the result of the write method of this property. Regards Eduardo |
Tue, Jul 22 2008 1:17 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Eduardo,
<< I think I have to change to use BookMarks (without index change) but TBookmark is a Pointer and I have an inherited TEDBTable and I want to create a special property RecordId or something else to act like Recno in DBISAM. There is a manner to convert a Pointer type to an integer ? >> Just cast it, like this: MyInteger:=Integer(MyPointer); Under 32-bit OS's, a Pointer is an Integer, and vice-versa, so you may not even need the cast. However, you may want to keep it there for clarity purposes. -- Tim Young Elevate Software www.elevatesoft.com |
Wed, Jul 23 2008 6:27 AM | Permanent Link |
"Eduardo [HPro]" | Tim
I am glad to receive this information. What do you think about this approach ? Just to remember, I am comming from DBISAM and I have many application that uses Recno, and therefore I need to use it at least for conversion purposes. Eduardo |
Wed, Jul 23 2008 1:37 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Eduardo,
<< What do you think about this approach ? >> It should work just fine. -- Tim Young Elevate Software www.elevatesoft.com |
Wed, Jul 23 2008 2:50 PM | Permanent Link |
"Eduardo [HPro]" | Tim
It is already working like I expect but I have to worry about FreeBookMark ? Or it will be free after table destroy ? THProTable = class(TEDBTable); private function GetMyRecno: Integer; procedure SetMyRecno(Value: Integer); public property Recno: Integer read GetMyRecno write SetMyRecno; end; function THProTable.GetMyRecno: Integer; begin Result := Integer(GetBookMark); end; // SetMyRecno ///////////// procedure THProTable.SetMyRecno(Value: Integer); begin if BookMarkValid(Pointer(Value)) then begin GotoBookMark(Pointer(Value)); end; end; Eduardo |
Wed, Jul 23 2008 3:27 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Eduardo,
<< It is already working like I expect but I have to worry about FreeBookMark ? Or it will be free after table destroy ? >> You'll want to free the bookmarks, or else they will accumulate. If you're always using RecNo in a Get/Set pattern, just free the bookmark in the Set method after the "if BookmarkValid" block like this: procedure THProTable.SetMyRecno(Value: Integer); begin if BookMarkValid(Pointer(Value)) then begin GotoBookMark(Pointer(Value)); end; FreeBookmark(Pointer(Value)); end; -- Tim Young Elevate Software www.elevatesoft.com |
Thu, Jul 24 2008 4:47 PM | Permanent Link |
"Eduardo [HPro]" | Tim
I was thinking about the FreeBookMark and I tought the more elegant solution is using a bookmark array (internal in the component) and for each GetBookMark I hold the value in this array and don´t free it like you describe, but when the table will be closed the component free all the array of bookmarks. In this manner I avoid situations like below: var nRec: Integer; begin nRec := Table.Recno; // Do something that can produce errors Table.Recno := nRec; <--- HERE *** end; *** Some times this code will never run and with my situation (migrating from DBISAM) it will be painful to change to a try...except code. That is the main reason to create this Recno property internally. Eduardo |
Thu, Jul 24 2008 5:26 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Eduardo,
<< I was thinking about the FreeBookMark and I tought the more elegant solution is using a bookmark array (internal in the component) and for each GetBookMark I hold the value in this array and don´t free it like you describe, but when the table will be closed the component free all the array of bookmarks. In this manner I avoid situations like >> Yes, I was thinking that it might be an issue. A bookmark array will certainly suffice in such a situation. -- Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Tuesday, April 30, 2024 at 03:55 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |