From e2c8f958b203228591c95de0875ebc5453adb62b Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Tue, 28 Jun 2016 13:43:32 +0000 Subject: [PATCH] tvplanit: declare IDs as Integer again, not Int64 - causing too much trouble with TVpIniDataStore git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4853 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/tvplanit/source/vpadvds.pas | 4 +-- components/tvplanit/source/vpbaseds.pas | 2 +- components/tvplanit/source/vpbdeds.pas | 4 +-- components/tvplanit/source/vpbufds.pas | 4 +-- components/tvplanit/source/vpdata.pas | 36 +++++++++++----------- components/tvplanit/source/vpdbisamds.pas | 4 +-- components/tvplanit/source/vpff2ds.pas | 4 +-- components/tvplanit/source/vpflxds.pas | 4 +-- components/tvplanit/source/vpinids.pas | 22 ++++++------- components/tvplanit/source/vpsqlds.pas | 4 +-- components/tvplanit/source/vpsqlite3ds.pas | 4 +-- components/tvplanit/source/vpzeosds.pas | 4 +-- 12 files changed, 48 insertions(+), 48 deletions(-) diff --git a/components/tvplanit/source/vpadvds.pas b/components/tvplanit/source/vpadvds.pas index 7f948d1ab..ca67e8550 100644 --- a/components/tvplanit/source/vpadvds.pas +++ b/components/tvplanit/source/vpadvds.pas @@ -71,7 +71,7 @@ type constructor Create(AOwner: TComponent); override; destructor Destroy; override; - function GetNextID(TableName: string): int64; override; + function GetNextID(TableName: string): integer; override; procedure Load; override; procedure CreateTable(TableName: string); procedure CreateIndexDefs(const TableName : string; @@ -220,7 +220,7 @@ begin end; {=====} -function TVpAdvDataStore.GetNextID(TableName: string): Int64; +function TVpAdvDataStore.GetNextID(TableName: string): Integer; var Query: TAdsQuery; GotIt: Boolean; diff --git a/components/tvplanit/source/vpbaseds.pas b/components/tvplanit/source/vpbaseds.pas index 0a306ab5c..a037f8b65 100644 --- a/components/tvplanit/source/vpbaseds.pas +++ b/components/tvplanit/source/vpbaseds.pas @@ -239,7 +239,7 @@ type procedure DeregisterAllWatchers; procedure DeregisterWatcher (Watcher : THandle); - function GetNextID(TableName: string): Int64; virtual; abstract; + function GetNextID(TableName: string): Integer; virtual; abstract; property Resources: TVpResources read FResources; procedure Load; virtual; procedure LoadEvents; virtual; abstract; diff --git a/components/tvplanit/source/vpbdeds.pas b/components/tvplanit/source/vpbdeds.pas index d02b3099c..ee1926d15 100644 --- a/components/tvplanit/source/vpbdeds.pas +++ b/components/tvplanit/source/vpbdeds.pas @@ -79,7 +79,7 @@ type constructor Create(AOwner: TComponent); override; destructor Destroy; override; - function GetNextID(TableName: string): int64; override; + function GetNextID(TableName: string): integer; override; procedure Load; override; procedure CreateTable(TableName: string); procedure CreateIndexDefs(const TableName : string; @@ -250,7 +250,7 @@ begin end; {=====} -function TVpBDEDataStore.GetNextID(TableName: string): Int64; +function TVpBDEDataStore.GetNextID(TableName: string): Integer; var Query: TQuery; GotIt: Boolean; diff --git a/components/tvplanit/source/vpbufds.pas b/components/tvplanit/source/vpbufds.pas index cd96d9a41..089c15499 100644 --- a/components/tvplanit/source/vpbufds.pas +++ b/components/tvplanit/source/vpbufds.pas @@ -28,7 +28,7 @@ type function GetTasksTable: TDataset; override; { ancestor methods } - function GetNextID(TableName: string): int64; override; + function GetNextID(TableName: string): integer; override; procedure Loaded; override; procedure SetConnected(const Value: boolean); override; @@ -153,7 +153,7 @@ begin Result := FContactsTable; end; -function TVpBufDSDataStore.GetNextID(TableName: string): int64; +function TVpBufDSDataStore.GetNextID(TableName: string): integer; begin { This is not needed in the BufDataset datastore as these tables use autoincrement fields. } diff --git a/components/tvplanit/source/vpdata.pas b/components/tvplanit/source/vpdata.pas index 2fae21539..77c1a8858 100644 --- a/components/tvplanit/source/vpdata.pas +++ b/components/tvplanit/source/vpdata.pas @@ -74,20 +74,20 @@ type FOwner: TObject; FResourceList: TList; function Compare(Descr1, Descr2: string): Integer; - function GetItem(Index: Int64): TVpResource; + function GetItem(Index: Integer): TVpResource; function GetCount: Integer; - function NextResourceID: Int64; + function NextResourceID: Integer; public constructor Create(Owner: TObject); destructor Destroy; override; - function AddResource(ResID: Int64): TVpResource; + function AddResource(ResID: Integer): TVpResource; function FindResourceByName(AName : string) : TVpResource; function GetResource(ID: Integer): TVpResource; procedure ClearResources; procedure RemoveResource(Resource: TVpResource); procedure Sort; property Count: Integer read GetCount; - property Items[Index: Int64]: TVpResource read GetItem; + property Items[Index: Integer]: TVpResource read GetItem; property Owner: TObject read FOwner; end; @@ -172,9 +172,9 @@ type public constructor Create(Owner: TVpResource); destructor Destroy; override; - function AddEvent(RecordID: Int64; StartTime, EndTime: TDateTime): TVpEvent; + function AddEvent(RecordID: Integer; StartTime, EndTime: TDateTime): TVpEvent; procedure DeleteEvent(Event: TVpEvent); - function GetEvent(Index: Int64): TVpEvent; + function GetEvent(Index: Integer): TVpEvent; function RepeatsOn(Event: TVpEvent; Day: TDateTime): Boolean; procedure Sort; procedure ClearEvents; @@ -203,7 +203,7 @@ type FAlarmAdv: Integer; FAlertDisplayed: Boolean; FAlarmAdvType: TVpAlarmAdvType; - FRecordID: Int64; + FRecordID: Integer; FLocation: string; FNotes: string; FDescription: string; @@ -238,7 +238,7 @@ type procedure SetEndTime(Value: TDateTime); procedure SetLocation(const Value: String); procedure SetNotes(const Value: string); - procedure SetRecordID(Value: Int64); + procedure SetRecordID(Value: Integer); procedure SetStartTime(Value: TDateTime); procedure SetCustInterval(Value: Integer); procedure SetRepeatCode(Value: TVpRepeatType); @@ -253,7 +253,7 @@ type property Changed: Boolean read FChanged write SetChanged; property Deleted: Boolean read FDeleted write SetDeleted; property ItemIndex: Integer read FItemIndex; - property RecordID : Int64 read FRecordID write SetRecordID; + property RecordID : Integer read FRecordID write SetRecordID; property StartTime : TDateTime read FStartTime write SetStartTime; property EndTime : TDateTime read FEndTime write SetEndTime; property Description : string read FDescription write SetDescription; @@ -302,7 +302,7 @@ type procedure BatchUpdate(value: Boolean); procedure Sort; function Compare(Item1, Item2: TVpTask): Integer; - function AddTask(RecordID: Int64): TVpTask; + function AddTask(RecordID: Integer): TVpTask; function Count : Integer; function CountByDay(Date: TDateTime): Integer; function Last: TVpTask; @@ -580,7 +580,7 @@ begin end; {=====} -function TVpResources.GetItem(Index: Int64): TVpResource; +function TVpResources.GetItem(Index: Integer): TVpResource; begin result := TVpResource(FResourceList.List^[Index]); end; @@ -592,10 +592,10 @@ begin end; {=====} -function TVpResources.NextResourceID: Int64; +function TVpResources.NextResourceID: Integer; var I : Integer; - ID: Int64; + ID: Integer; Res: TVpResource; begin ID := 0; @@ -609,7 +609,7 @@ begin end; {=====} -function TVpResources.AddResource(ResID: Int64): TVpResource; +function TVpResources.AddResource(ResID: Integer): TVpResource; var Resource : TVpResource; begin @@ -980,7 +980,7 @@ begin end; {=====} -procedure TVpEvent.SetRecordID(Value: Int64); +procedure TVpEvent.SetRecordID(Value: Integer); begin if Value <> FRecordID then begin FRecordID := Value; @@ -1119,7 +1119,7 @@ end; {=====} {Adds the event to the eventlist and returns a pointer to it, or nil on failure} -function TVpSchedule.AddEvent(RecordID: Int64; StartTime, +function TVpSchedule.AddEvent(RecordID: Integer; StartTime, EndTime: TDateTime): TVpEvent; begin result := nil; @@ -1175,7 +1175,7 @@ begin end; {=====} -function TVpSchedule.GetEvent(Index: Int64): TVpEvent; +function TVpSchedule.GetEvent(Index: Integer): TVpEvent; begin { Returns an event on success or nil on failure } result := FEventList.Items[Index]; @@ -2132,7 +2132,7 @@ begin end; {=====} -function TVpTasks.AddTask(RecordID: Int64): TVpTask; +function TVpTasks.AddTask(RecordID: Integer): TVpTask; var Task: TVpTask; begin diff --git a/components/tvplanit/source/vpdbisamds.pas b/components/tvplanit/source/vpdbisamds.pas index a2266bd50..c46020a85 100644 --- a/components/tvplanit/source/vpdbisamds.pas +++ b/components/tvplanit/source/vpdbisamds.pas @@ -75,7 +75,7 @@ type constructor Create(AOwner: TComponent); override; destructor Destroy; override; - function GetNextID(TableName: string): Int64; override; + function GetNextID(TableName: string): Integer; override; procedure Load; override; procedure CreateTable(TableName: string); procedure CreateIndexDefs(const TableName : string; IndexDefs : TIndexDefs); override; @@ -249,7 +249,7 @@ begin end; {=====} -function TVpDBISAMDataStore.GetNextID(TableName: string): Int64; +function TVpDBISAMDataStore.GetNextID(TableName: string): Integer; var Query: TDBISAMQuery; GotIt: Boolean; diff --git a/components/tvplanit/source/vpff2ds.pas b/components/tvplanit/source/vpff2ds.pas index 4963be0b0..3e797b0e1 100644 --- a/components/tvplanit/source/vpff2ds.pas +++ b/components/tvplanit/source/vpff2ds.pas @@ -77,7 +77,7 @@ type constructor Create(AOwner: TComponent); override; destructor Destroy; override; - function GetNextID(TableName: string): int64; override; + function GetNextID(TableName: string): integer; override; // procedure PurgeResource(Res: TVpResource); override; procedure PurgeEvents(Res: TVpResource); override; @@ -138,7 +138,7 @@ begin end; {=====} -function TVpFF2DataStore.GetNextID(TableName: string): int64; +function TVpFF2DataStore.GetNextID(TableName: string): integer; begin { this is not used in the FlashFiler Datastore as the FlashFiler tables use } { autoincrement fields } diff --git a/components/tvplanit/source/vpflxds.pas b/components/tvplanit/source/vpflxds.pas index c162e92c8..1c62afd7c 100644 --- a/components/tvplanit/source/vpflxds.pas +++ b/components/tvplanit/source/vpflxds.pas @@ -160,7 +160,7 @@ type procedure PurgeTasks(Res: TVpResource); override; function GetFieldName(Mappings: TCollection; VPField: string): string; - function GetNextID(TableName: string): Int64; override; + function GetNextID(TableName: string): Integer; override; { These are published via the TVpDataSources class, which allows them to } { be clustered in the Object Inspector Don't publish them individually } @@ -2041,7 +2041,7 @@ begin end; {=====} -function TVpFlexDataStore.GetNextID(TableName: string): Int64; +function TVpFlexDataStore.GetNextID(TableName: string): Integer; begin { The FlexDataStore has no idea what type of database you are connected to } { beyond TDataset compatibility, so it cannot presume to generate record } diff --git a/components/tvplanit/source/vpinids.pas b/components/tvplanit/source/vpinids.pas index a0cfc11d1..049498a36 100644 --- a/components/tvplanit/source/vpinids.pas +++ b/components/tvplanit/source/vpinids.pas @@ -30,7 +30,7 @@ type procedure SetConnected(const AValue: Boolean); override; procedure Split(const AString: String; AList: TStrings); - function UniqueID(AValue: Int64): Boolean; + function UniqueID(AValue: Integer): Boolean; procedure ReadFromIni; procedure WriteToIni; @@ -39,7 +39,7 @@ type constructor Create(AOwner: TComponent); override; destructor Destroy; override; - function GetNextID(TableName: string): Int64; override; + function GetNextID(TableName: string): Integer; override; procedure LoadEvents; override; procedure LoadContacts; override; procedure LoadTasks; override; @@ -169,14 +169,14 @@ begin AEvent.UserField9 + '}'; end; -function TVpIniDatastore.GetNextID(TableName: string): Int64; +function TVpIniDatastore.GetNextID(TableName: string): Integer; begin repeat - Result := Random(High(Int64)); - until UniqueID(Result); + Result := Random(High(Integer)); + until UniqueID(Result) and (Result <> -1); end; -function TVpIniDatastore.UniqueID(AValue: Int64): Boolean; +function TVpIniDatastore.UniqueID(AValue: Integer): Boolean; var i, j: Integer; res: TVpResource; @@ -572,7 +572,7 @@ var i,j: Integer; s: String; key: String; - resID, id: Int64; + resID, id: Integer; begin if FFileName = '' then exit; @@ -588,7 +588,7 @@ begin s := ini.ReadString('Resources', ResList[i], ''); if s = '' then IniError(RSIniFileStructure); - resID := StrToInt64(ResList[i]); + resID := StrToInt(ResList[i]); res := Resources.AddResource(resID); StrToResource(s, res); @@ -596,7 +596,7 @@ begin L.Clear; ini.ReadSection(key, L); for j:=0 to L.Count-1 do begin - id := StrToInt64(L[j]); + id := StrToInt(L[j]); contact := res.Contacts.AddContact(id); s := ini.ReadString(key, L[j], ''); StrToContact(s, contact); @@ -607,7 +607,7 @@ begin L.Clear; ini.ReadSection(key, L); for j:=0 to L.Count-1 do begin - id := StrToInt64(L[j]); + id := StrToInt(L[j]); event := res.Schedule.AddEvent(id, 0, 1); s := ini.ReadString(key, L[j], ''); StrToEvent(s, event); @@ -617,7 +617,7 @@ begin L.Clear; ini.ReadSection(key, L); for j:=0 to L.Count-1 do begin - id := StrToInt64(L[j]); + id := StrToInt(L[j]); task := res.Tasks.AddTask(id); s := ini.ReadString(key, L[j], ''); StrToTask(s, task); diff --git a/components/tvplanit/source/vpsqlds.pas b/components/tvplanit/source/vpsqlds.pas index f60017638..5292470f0 100644 --- a/components/tvplanit/source/vpsqlds.pas +++ b/components/tvplanit/source/vpsqlds.pas @@ -106,7 +106,7 @@ type // returns the next id for a store by doing an equivalent of select max(id) from table // and increasing the number by one - function GetNextID(TableName: string): Int64; override; + function GetNextID(TableName: string): Integer; override; // post changes to the store procedure PostResources; override; @@ -333,7 +333,7 @@ begin result:=Stores[TasksTableName].Dataset; end; -function TVPSQLDataStore.GetNextID(TableName: string): Int64; +function TVPSQLDataStore.GetNextID(TableName: string): Integer; var FldName : string; begin diff --git a/components/tvplanit/source/vpsqlite3ds.pas b/components/tvplanit/source/vpsqlite3ds.pas index 3dff12ea0..b23e0bcfa 100644 --- a/components/tvplanit/source/vpsqlite3ds.pas +++ b/components/tvplanit/source/vpsqlite3ds.pas @@ -33,7 +33,7 @@ type public constructor Create(AOwner: TComponent); override; procedure CreateTables; - function GetNextID(TableName: string): int64; override; + function GetNextID(TableName: string): integer; override; procedure PostEvents; override; procedure PostContacts; override; procedure PostTasks; override; @@ -277,7 +277,7 @@ begin Result := FEventsTable; end; -function TVpSqlite3DataStore.GetNextID(TableName: string): int64; +function TVpSqlite3DataStore.GetNextID(TableName: string): integer; begin { This is not needed in the SQLITE3 datastore as these tables use autoincrement fields. } diff --git a/components/tvplanit/source/vpzeosds.pas b/components/tvplanit/source/vpzeosds.pas index 1d3d04621..fb3cee6e2 100644 --- a/components/tvplanit/source/vpzeosds.pas +++ b/components/tvplanit/source/vpzeosds.pas @@ -33,7 +33,7 @@ type public constructor Create(AOwner: TComponent); override; procedure CreateTables; - function GetNextID(TableName: string): int64; override; + function GetNextID(TableName: string): integer; override; property ResourceTable; property EventsTable; @@ -257,7 +257,7 @@ begin Result := FEventsTable; end; -function TVpZeosDataStore.GetNextID(TableName: string): int64; +function TVpZeosDataStore.GetNextID(TableName: string): integer; begin { This is not needed in the ZEOS datastore as these tables use autoincrement fields. }