Jump to content

programmerdelphi2k

Members
  • Content Count

    1406
  • Joined

  • Last visited

  • Days Won

    22

Everything posted by programmerdelphi2k

  1. ... DP was invaded by chatBOT 🤗
  2. I think that a simple "LIBRARY path = << your folder with files >>" will be enough, not? then, you can have any folders with any version... and in your "Tools->Language->Delphi->Library" you can define "where (folder) find your files", for each platform used! LIBRARY path = dcus compiled (release) or your ".pas" to compile in-time BROWSE path = your ".PAS" to Code Editor help you when coding... DEBUG dcu path = dcus used when in Debug mode! NOTE: you can use "SEARCH ..." in your project: Project->Options->Delphi Compiler->Search Path that way, you dont need use "LIB" folder from RAD!
  3. programmerdelphi2k

    Access to Google Calendar via Delphi

    https://www.clevercomponents.com/articles/article038/ "CleverComponents" is paid suite but in Github it can help you start with your code... https://github.com/CleverComponents/Google-Calendar-API
  4. programmerdelphi2k

    How to add components to a new "Component Toolbar" page

    RegisterComponents https://docwiki.embarcadero.com/Libraries/Alexandria/en/System.Classes.RegisterComponents
  5. programmerdelphi2k

    Tlistview SQLite pagination

    ok!
  6. programmerdelphi2k

    Need a "Delphi programming guideline"

    about the nomenclatures, really, only the programmer can define it. But the IDE provides some internal tools that can help in the quest to produce better coding or even improve the look (for better readability). Tools->Language->Formatter: reformating you code with CTRL+D (I love this) on unit or for all project: Project-> Format Project Sources you can create your "way" ( as you named all procedure/functions/vars/objects/etc.. ), then, the "formatter" will use as your "pattern" to fix all next occurrences -> it's great helper! the main idea, it's create the first occurrences (names) then the "formatter" will use it! in Project->QA Metrics, QA Audits -> you will have some info about your project with some tips about your coding in Project -> Method Toxicity Metrcis -> you will know "how is it?" a general idea of how your code is doing, with respect to complexity (which can affect performance) But nothing will save you from a sloppy project manager! If the boss doesn't care, who needs that boss!
  7. programmerdelphi2k

    Generic from the RTL for sorted list of objects

    remember: you can use Arrays (a little complicated, but possible ) as your container instead TObjectList or TDictionary, of course, without many benefits, by other side, without many intrincics TList memory usage. Arr := Arr + [ obj ] dic = a litlle more complicated here ( a "record" can help you )
  8. programmerdelphi2k

    Generic from the RTL for sorted list of objects

    my test for TObject or any other type, you can create yourself class for easy access using another types -- not copyed, not chatBOTs >:))) implementation {$R *.dfm} uses System.Generics.Collections; type TMyObjList = TObjectList<TObject>; TMyDicObjList = TDictionary<string, TMyObjList>; var LDic: TMyDicObjList; procedure MyShowingObjects(const ADic: TMyDicObjList; const LClearMemo: boolean = false); var LText: string; begin for var K in ADic do begin LText := LText + '...Key = ' + K.Key + ', Addr = ' + integer(K.Value).ToString + slinebreak; // for var V in TMyObjList(K.Value) do LText := LText + '......Value = ' + V.ToString + ', Addr = ' + integer(V).ToString + slinebreak; end; // if LClearMemo then Form1.Memo1.Text := LText else Form1.Memo1.Lines.Add(LText); end; procedure MyFreeObjectsFromList(const ADic: TMyDicObjList); //var // LO: TMyObjList; begin while (LDic.Count > 0) do begin for var K in LDic.Keys do begin //if LDic.TryGetValue(K, LO) then // I forgot that I use "True" param in "LDic.Add(LKey, TMyObjList.Create(true));"!!! // begin // for var V in LO do // LDic[K].Remove(V); // remove TObject // FreeAndNil(LDic[K]); // remove TObjectList // end; // LDic.Remove(K); // remove Keys end; end; end; function MyFindObject(const ADic: TMyDicObjList; const AKey: string = ''; const AObjAddress: integer = 0): TObject; begin result := nil; // if (ADic = nil) or (ADic.Count = 0) or (AObjAddress < 1) then exit; // if (AKey = '') then begin for var K in ADic.Keys do for var O in ADic[K] do if integer(O) = AObjAddress then exit(O); end else begin if ADic.ContainsKey(AKey) then for var O in ADic[AKey] do if integer(O) = AObjAddress then exit(O); end; end; procedure TForm1.FormCreate(Sender: TObject); begin LDic := TMyDicObjList.Create; end; procedure TForm1.FormDestroy(Sender: TObject); begin MyFreeObjectsFromList(LDic); // LDic.Free; end; procedure TForm1.BtnAddObjectListHelloClick(Sender: TObject); var LKey: string; begin LKey := BtnAddObjectListHello.Caption; // if not LDic.ContainsKey(LKey) then LDic.Add(LKey, TMyObjList.Create(true)); // LDic[LKey].Add(TObject.Create); // MyShowingObjects(LDic, true); end; procedure TForm1.BtnAddObjectListWolrdClick(Sender: TObject); var LKey: string; begin LKey := BtnAddObjectListWolrd.Caption; // if not LDic.ContainsKey(LKey) then LDic.Add(LKey, TMyObjList.Create(true)); // LDic[LKey].Add(TObject.Create); // MyShowingObjects(LDic, true); end; procedure TForm1.BtnGetObjectOnListClick(Sender: TObject); var O: TObject; begin O := MyFindObject(LDic, Trim(EdtKey.Text), StrToIntDef(EdtAddress.Text, -1)); // by address or any other from class! // if (O <> nil) then Memo1.Lines.Add('Obj found = ' + integer(O).ToString) else Memo1.Lines.Add('Obj = Not Found'); end; procedure TForm1.BtnDeleteAllObjectsClick(Sender: TObject); begin MyFreeObjectsFromList(LDic); // MyShowingObjects(LDic, true); end; initialization ReportMemoryLeaksOnShutdown := true; end.
  9. programmerdelphi2k

    Generic from the RTL for sorted list of objects

    always and act for impulse! 😁
  10. programmerdelphi2k

    "Divided by zero" exception

    im come from DBase III Plus and Clipper Summer 87... any error was not an exception, but a fact! (I jumped MSX Basic)😁
  11. programmerdelphi2k

    "Divided by zero" exception

    if doesnt, then it's solved! thanks
  12. programmerdelphi2k

    "Divided by zero" exception

    ok, then, the answer "in simple term" is: not acceptable! break now, dont hurt me later! this would be my point, from "layman"-math thanks
  13. programmerdelphi2k

    FireDAC open error

    about Firebird usage, not problem at all! you can choice between 3 connnection type: this is not about database usage, just "about the connection type used by FireDAC" PERSISTENT: with-name, using FDConnectionDefs.ini (done in Design-Time) PRIVATE: with-name, not stored on FDConnectionDefs.ini (done in Design-Time) TEMPORARY: without-name, and done on code! https://docwiki.embarcadero.com/RADStudio/Sydney/en/Defining_Connection_(FireDAC) just inform the right params to find the "FDB" file, as well as the library (FBClient.DLL) path! Else, the FireDAC will try find in default system folders you can have a "FDConnectionsDef.ini" in your exe folder! not needs use the Embarcadero default!
  14. programmerdelphi2k

    FireDAC open error

    in fact, you can do the "backup" as any other file-DB! type TForm1 = class(TForm) FDConnection1: TFDConnection; FDPhysSQLiteDriverLink1: TFDPhysSQLiteDriverLink; FDGUIxWaitCursor1: TFDGUIxWaitCursor; Button1: TButton; DBGrid1: TDBGrid; DataSource1: TDataSource; FDQuery1: TFDQuery; Button2: TButton; FDSQLiteBackup1: TFDSQLiteBackup; DBGrid2: TDBGrid; FDConnection2: TFDConnection; FDQuery2: TFDQuery; DataSource2: TDataSource; Button3: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin FDConnection1.Params.Database := ':memory:'; FDConnection1.ExecSQL('create table mytable(id integer, names varchar(20));'); FDConnection1.ExecSQL('insert into mytable values(1, ''john'');'); FDConnection1.ExecSQL('insert into mytable values(2, ''mary'');'); FDConnection1.ExecSQL('insert into mytable values(3, ''peter'');'); FDQuery1.Open('select * from mytable'); end; procedure TForm1.Button2Click(Sender: TObject); begin FDSQLiteBackup1.DriverLink := FDPhysSQLiteDriverLink1; FDSQLiteBackup1.DatabaseObj := FDConnection1.CliObj; // <-- your DB opened on FDConnnect1 -> :memory: in case! FDSQLiteBackup1.DestDatabase := 'mySQLiteTarget.db'; // <-- file to save on disk or you can target to another ":memory:" FDSQLiteBackup1.Backup; end; procedure TForm1.Button3Click(Sender: TObject); begin FDConnection2.Close; FDConnection2.Params.Database := 'mySQLiteTarget.db'; FDConnection2.DriverName := 'SQLite'; FDQuery2.Open('select * from mytable'); end; end. ... object FDConnection1: TFDConnection Params.Strings = ( 'DriverID=SQLite') end object FDPhysSQLiteDriverLink1: TFDPhysSQLiteDriverLink end object FDGUIxWaitCursor1: TFDGUIxWaitCursor Provider = 'Forms' end object DataSource1: TDataSource DataSet = FDQuery1 end object FDQuery1: TFDQuery Connection = FDConnection1 end object FDSQLiteBackup1: TFDSQLiteBackup Catalog = 'MAIN' DestCatalog = 'MAIN' end object FDConnection2: TFDConnection end object FDQuery2: TFDQuery Connection = FDConnection2 end object DataSource2: TDataSource DataSet = FDQuery2 end end
  15. programmerdelphi2k

    Free installation error

    these screen show just "Wellcome page" with problem... you can disable it if you want (in menu Tools or just dont load the BPLs "wellcome****" in your Registry key) well, if the RAD was installed then all library can be load on start... do you can start a new project? try create a project do you have the default components? see Components menu etc... if the answer is not, then, exists a real-problem with installation!
  16. programmerdelphi2k

    "Divided by zero" exception

    as said Phill Collins: "...Can you feel it coming in the air tonight, oh lord, oh lord... Well I've been waiting for this moment for all my life, oh lord, oh lord" I think that I would can ... and would kill it... but the question is: where "number/0" would be acceptable allowing to continue the task? this the question in my question!
  17. programmerdelphi2k

    Free installation error

    then, you need contact Embarcadero
  18. programmerdelphi2k

    "Divided by zero" exception

    hi folk, I have a question within the scope of this topic (and from a layman in mathematics concepts): in which moment or scenario, it would be interesting to "don't throw an exception (number/0=OK go ahead, see you later)"? that is, would this not imply an error of even greater consequence later, if no way of "stopping" the process was done immediately?
  19. programmerdelphi2k

    Free installation error

    first, CAN YOU USE A NEW INSTALL with your license? see this firtly. uninstall your RAD restart Mswin delete the Embarcadero folders: all c:\programadata\<<name in GUID values>> normally 3 folders on top Explorer list <--- here your license is stored, see what folder is used c:\users\<<your user>>\...Local and Roaming\Embarcadero REGISTRY keys in: HLM\Wow32...\Embarcadero HCU\Software\Embarcadero see your PATH environmentvariable and delete any RAD references now, you can restart and install new RAD again
  20. programmerdelphi2k

    Free installation error

    MS Hosts/Firewall/Antivirus file block any Embarcadero ip? the license has exceeded the number of installations? <---- sorry, I have ask you: license is valid for your RADversion? Did you try in my.embarcadero.com download your license file? did you try install using ISO (not web install)?
  21. programmerdelphi2k

    Threaded FTP and Timeouts

    NOTE: Any exception that occurs within a thread will cause its termination immediately! (immediately = it should be, but not necessary) However, the consequences depend on what you were doing at that moment! why 18mins? I dont know! It's necessary see your project and test it ... (I dont iOS)! I think that it's not real for a "unconnected network"!!! Preferably, NEVER make direct access to visual components inside a thread!!! You should not use this type of coding within a thread, generally speaking! If the visual object was not created or no longer exists = error If the visual object is not thread safe (it usually isn't) = error Thus, if it is really necessary to make this access, always use "Thread.Synchronize() = force an immediate access; or Thread.Queue() = access when you can; That's what these two procedures are for in the TThread class! you can store your "error messages" in a property from the class, then, you can review it any time! some like this: type TMyProc = procedure(AValue: TArray<string>) of object; // your params... TMyThread = class(TThread) private FTries : integer; FIdFTP : TIdFTP; FProc : TMyProc; FFileToTransfer: string; FMyErrors : TArray<string>; protected procedure Execute; override; public constructor Create(const ASuspended: boolean; const AFileToTransfer: string; const AProc: TMyProc; const ATries: integer = 1); destructor Destroy; override; // property MyErrors: TArray<string> read FMyErrors; // if you want store each message! else, dont use this! end; implementation { TMyThread } constructor TMyThread.Create(const ASuspended: boolean; const AFileToTransfer: string; const AProc: TMyProc; const ATries: integer = 1); begin inherited Create(ASuspended); // FreeOnTerminate := true; FIdFTP := TIdFTP.Create(nil); FProc := AProc; FFileToTransfer := AFileToTransfer; FMyErrors := []; FTries := ATries; // test for example: if <1 and >10 then =1 end; destructor TMyThread.Destroy; begin FIdFTP.Free; // inherited; end; procedure TMyThread.Execute; var LTry: integer; begin FMyErrors := []; LTry := 1; // try while not(Terminated) and (LTry <= FTries) do begin try FIdFTP.Connect; except // on E: Exception do // for any case begin LTry := LTry + 1; FMyErrors := FMyErrors + [Exception(ExceptObject).message]; // if Assigned(FProc) then FProc([Exception(ExceptObject).message]); // sleep(500); end; end; end; finally FIdFTP.Disconnect; end; end; end. type TForm1 = class(TForm) //.. procedure Button1Click(Sender: TObject); private procedure MyUpdateUI(AParam: TArray<string>); // your procedure... your params end; implementation {$R *.dfm} uses Unit2; procedure TForm1.MyUpdateUI(AParam: TArray<string>); begin Memo1.Lines.AddStrings(AParam); end; procedure TForm1.Button1Click(Sender: TObject); var MyThread: TMyThread; begin MyThread := TMyThread.Create(true, '', MyUpdateUI, 3); MyThread.Start; end;
  22. programmerdelphi2k

    Threaded FTP and Timeouts

    I think that is your "Form1" usage into a thread! try some like this: unit Unit2; interface uses System.Classes, System.SysUtils, System.Threading, // IdBaseComponent, // IdComponent, // IdTCPConnection, // IdTCPClient, // IdExplicitTLSClientServerBase, IdFTP; type TMyProc = procedure(AValue: string) of object; // your params... TMyThread = class(TThread) private FIdFTP : TIdFTP; FProc : TMyProc; FFileToTransfer: string; protected procedure Execute; override; public constructor Create(const ASuspended: boolean; const AFileToTransfer: string; const AProc: TMyProc); destructor Destroy; override; // // etc... end; implementation { TMyThread } constructor TMyThread.Create(const ASuspended: boolean; const AFileToTransfer: string; const AProc: TMyProc); begin inherited Create(ASuspended); // FreeOnTerminate := true; FIdFTP := TIdFTP.Create(nil); FProc := AProc; FFileToTransfer := AFileToTransfer; end; destructor TMyThread.Destroy; begin FIdFTP.Free; // inherited; end; procedure TMyThread.Execute; begin if (FIdFTP = nil) or (FFileToTransfer='') then exit; // // ... use "FIdFTP" now with your FFileToTransfer or a list of files... { TThread.Synchronize(nil, procedure begin // update your UI here... end); // // or just if Assigned(FProc) then FProc('hello world'); // this run in your main-thread = app! } end; end. type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private procedure MyUpdateUI(AParam: string); // your procedure... your params public end; var Form1: TForm1; implementation {$R *.dfm} uses Unit2; procedure TForm1.MyUpdateUI(AParam: string); begin // what to do? end; procedure TForm1.Button1Click(Sender: TObject); var MyThread: TMyThread; begin MyThread := TMyThread.Create(true, 'myfile.txt', MyUpdateUI); MyThread.Start; end; end.
  23. programmerdelphi2k

    Tlistview SQLite pagination

    to avoid more clicks... procedure TForm1.Button1Click(Sender: TObject); begin CustomerTable.ParamByName('N').AsInteger := LNextRecord; CustomerTable.Refresh; CustomerTable.Last; // if (LNextRecord >= CustomerTable.RecordCount) then // not more records... Button1.Enabled := false; // LNextRecord := LNextRecord + LDBGridVisibleRows; // CustomerTable.MoveBy(-LDBGridVisibleRows) end;
  24. programmerdelphi2k

    Threaded FTP and Timeouts

    maybe some like this: // OnCreate //FReconnectTime := 1; // this would be a private field in "YourThread" = private FReconnectTime : boolean;" // OnExecute(...) //... try while not(Terminated) and (FReconnectTime < 4) do begin try // Ftp connect... // Ftp transfers... // break; // get out here! except on E: Exception do begin // ... FReconnectTime := FReconnectTime + 1; // // maybe a "sleep( n )" for wait before new try... avoiding overhead end; end; end; finally // if Ftp disconnect... end;
  25. programmerdelphi2k

    Tlistview SQLite pagination

    using "Dataset" (FireDac or any other) you can try this: after your "SELECT" here my sample using a EMPLOYEE Interbase db: "SELECT * FROM CUSTOMER ROWS :N " --> N = param "Integer" implementation {$R *.dfm} //type // TMyHack = class(TDBGrid); var LDBGridVisibleRows: integer; LNextRecord : integer; procedure TForm1.FormCreate(Sender: TObject); begin LDBGridVisibleRows := 10; // TMyHack(DBGrid1).RowCount; // or your LV visible items on screen!!! LNextRecord := LDBGridVisibleRows; // CustomerTable.Open; end; procedure TForm1.Button1Click(Sender: TObject); begin CustomerTable.ParamByName('N').AsInteger := LNextRecord; CustomerTable.Refresh; CustomerTable.Last; // LNextRecord := LNextRecord + LDBGridVisibleRows; // CustomerTable.MoveBy(-LDBGridVisibleRows) end;
×