Jump to content

JonRobertson

Members
  • Content Count

    171
  • Joined

  • Last visited

  • Days Won

    3

Posts posted by JonRobertson


  1. The first thing to change is to set conPLife.Connected to False before building the project. When Dinobase launches and loads your main form, it is attempting to immediately open the database connection because Connected is set to True at design-time. Setting Connected to True is very useful while you are developing, but it needs to be set to False before building a project that will run anywhere except on your development machine. This is a pain and there are ways to automate it. But that is a different post. ;)

     

    I would have expected removing the path in Params.Database to resolve the path issue. But I do not have experience with SQLite or FireDAC. If you are certain the database will always be in the same folder as the .EXE, the path can be adjusted before opening the database. Here is one approach, which I put at the top of FormCreate:

    procedure TfrmDino.FormCreate(Sender: TObject);  //Form creation
    begin
      conPLife.Params.Database := IncludeTrailingPathDelimiter(TDirectory.GetCurrentDirectory) + conPLife.Params.Database;
      conPLife.Connected := True;
      tblPLife.Active := True;

    Note that System.IOUtils needs to be added to your uses clause to resolve the reference to TDirectory.

     

    This is still not ideal, but it works for your first project. An ideal solution would be to store the database and images in a folder intended for app data, such as TPath.GetPublicPath (typically C:\ProgramData). There are other folders that you could use. Through the years, Microsoft has changed gears on app data folders a few times.

     

    After that, I copied the dino_images and dino_size folders from your earlier zip to my project folder and was able to run your project, navigate the db, and see the images.

     

    I have a couple of quick suggestions from a brief look at your form's code. Your Exit button calls "self.Close". "self." is not needed here. There are times that it is useful for clarity, but not necessary. The btnExitClick method is a member of TfrmDino, so calling Close calls the Close method of TfrmDino.

     

    You declared sName, recno, and recnum as globals in the var section of the unit. You should get in the habit of declaring "form" related variables as members of the form, as private members when possible. (Although it seems recno and recnum are not currently needed.)

     

      private
        sName: String;

    Lastly, pay attention to warnings from the compiler:

     

    [dcc32 Warning] Dinobase_u.pas(126): W1036 Variable 'iSelect' might not have been initialized

    How should lbxDataClick "behave" if lbxData.ItemIndex is not greater than -1?

     

    Jon


  2. He meant don't use a modified TDBNavigator. You said at some point something about adding your own buttons.

     

    If the buttons provided by TDBNavigator provide the functionality you are wanting but you weren't able to get it to work as intended, that can be corrected. If you want additional buttons to provide functionality that is not built into TDBNavigator, that is a different story.

     

    For what you are doing, you should get the project working using single dataset component and a single datasource component. Based on your posts, it seems as though you may be using multiple datasets.

     

    I would use a separate dataset to load the picture. But that is easier to implement once the project works using a single dataset.

     

     


  3. 11 minutes ago, Columbo said:

    The path is correct but it seems as if it is not adding the sName but only the ',jpg'.

     

    That code would add sName. But sName may be an empty string ('') at that point of code execution.

     

    Have you confirmed that sName contains a value when LoadFromFile is called?

     

    Have you set a breakpoint to examine sName before LoadFromFile is called? Or added a ShowMessage(sName) before calling LoadFromFile?


  4. 8 minutes ago, Gary said:

    Can't help but think your table name being all uppercase is the problem. Try putting it in single quotes like above. I don't use SQLite so maybe someone else knows the problem for sure.

     

    I was able to get his project working on my machine. I don't use SQLite either. So as a test I tried several combinations of character case on the table name and they all worked. Table names (and likely any object name) do not seem to be case sensitive.

     

    His project also works with the database connection and query assigned 100% in code, with zero design-time configuration.


  5. On 12/4/2023 at 3:27 AM, PeterPanettone said:

    Only when creating a new project does it return to the default Package configuration. This is a real inconsistency!

    I disagree. No reason for the IDE to load packages if they won't be needed by my next action. My next action could be closing the IDE or loading a different project that also does not use all of the default packages.

     

    The only issue that occurs to me is if my next action was to create a new form, without loading or starting a project first. In that case, I may be confused why a package is not loaded that I would expect to be loaded.

     

    But I wouldn't want to change the design or code of a form without having a project loaded. There is a lot of IDE functionality unavailable in that scenario.


  6. 15 minutes ago, Columbo said:
    3 minutes ago, Columbo said:

    If I run the FDtest_p.exe I get the same ShowMessage as I mentioned in my previous post to Gary,  'D:\Delphi_11_Community\MyProjects\Data\dat2.sqlite '.

    Sure, because that is the path that you hardcoded to FDConnection1.Params.Database:

     

    15 minutes ago, Columbo said:

    FDConnection1.Params.Database := 'D:\Delphi_11_Community\MyProjects\Data\dat2.sqlite';

    Try this instead:

    FDConnection1.Params.Database := ExtractFilePath(Application.ExeName) + 'dat2.sqlite';

    If ExtractFilePath is an undefined identifier, add SysUtils to the uses statement below the implementation keyword.


  7. 1 hour ago, Columbo said:

    but how can I tell if there really is a connection to the database

    The easy way to test anything in programming is to intentionally break code. For example, in your SQLite project, change Database= to a file that you know does not exist. When I did that, I got a dialog saying "unable to open database file."

     

    Using the link you provided, I did that tutorial with the Employee.s3db database in Embarcadero's samples folder, and it worked as expected. And if I change the query to SELECT * from dat2, I get the same error you are (as I would expect with this database).

     

    Attached is my version of the tutorial project. Object names don't match the tutorial and I added output when no rows are returned. It attaches to a database named dat2.db in the same folder as the project.

     

    The screenshot you posted of the database & table did not have "data type" for each column. Are you sure you have completely created *and* saved the database? I used DB Browser for SQLite and there is a button to "Write Changes".

     

    My best guess is the database file that your Delphi project is opening does not have a table named dat2.

    Tutorial.zip


  8. I would not suggest jumping into the source of an IDE Expert.  There are many open source repos that could be beneficial. Here are a few, and these are just github. 

     

    Embarcadero GitHub - Project  samples included with the past several versions of Delphi and some other interesting repos.

     

    Delphi topic on GitHub - Over 2,200 open source projects

     

    Edit: This may be useful: Coding Boot Camp 2022


  9. Search engines are your friend. Here is a small list. None of these offer structure like a training course or a classroom curriculum. But there are some worthwhile articles and videos.

     

    https://delphi.fandom.com/wiki/Delphi_Wiki

    https://www.delphibasics.co.uk/

    Embarcadero YouTube

    LearnDelphi.tv

    Delphi Programming Tutorials

    Not free: Embarcadero Academy

     

    I personally prefer books. Shortly after I started using Delphi, my go to Delphi bibles were Mastering Delphi 2 and Delphi Developer's Handbook, both by Marco Cantu. Most everything in those books still apply, although they were written nearly 30 years ago. There are several good "current" Delphi books that would cover more recent language additions but may assume the reader already knows the basics.

     

    Coding in Delphi and More Coding in Delphi by Nick Hodges are good for the Delphi language itself. But check out other authors as well. There are a number of excellent books on Delphi by some great authors.

    • Thanks 1

  10. 27 minutes ago, Columbo said:

    Here is the contents of the ConnectDB_u.dfm:

    That isn't the ConnectDB_u.dfm for the ConnectDB_u.pas that you posted above. The name of the form in that DFM is TForm1 and none of the components on your TfrmConnectDB form are in the DFM code you posted. It should look more like this:

     

    object frmConnectDB: TfrmConnectDB
      Left = 0
      Top = 0
      Caption = 'frmConnectDB'
      ClientHeight = 442
      ClientWidth = 628
      Color = clBtnFace
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -12
      Font.Name = 'Segoe UI'
      Font.Style = []
      TextHeight = 15
      object btnConnect: TButton
        Left = 280
        Top = 232
        Width = 75
        Height = 25
        Caption = 'btnConnect'
        TabOrder = 0
        OnClick = btnConnectClick
      end
      object btnExecute: TButton
        Left = 280
        Top = 312
        Width = 75
        Height = 25
        Caption = 'btnExecute'
        TabOrder = 1
        OnClick = btnExecuteClick
      end
      object memOutput: TMemo
        Left = 320
        Top = 56
        Width = 185
        Height = 89
        TabOrder = 2
      end
      object SQLConnection1: TSQLConnection
        DriverName = 'Sqlite'
        Params.Strings = (
          'DriverUnit=Data.DbxSqlite'
            'DriverPackageLoader=TDBXSqliteDriverLoader,DBXSqliteDriver280.bp' +
            'l'
            'MetaDataPackageLoader=TDBXSqliteMetaDataCommandFactory,DbxSqlite' +
            'Driver280.bpl'
          'FailIfMissing=True'
          'Database=')
        Left = 304
        Top = 384
      end
      object SQLQuery1: TSQLQuery
        Params = <>
        Left = 416
        Top = 296
      end
    end

     


  11. Open ConnectDB_u.dfm in Notepad, copy entire contents to the clipboard, and paste that in a reply to this post.

     

    I am curious how SQLQuery1 is configured in the form designer. Another approach is to select SQLQuery1 in the form designer, press ctrl-c to copy just that component to the clipboard, and post it. But there could be other helpful details in the entire DFM, such as how SQLConnection1 is configured.


  12. Has anyone attempted to add VCL Styles support to TChromeTabs? In my search, I see Jerry Dodge asked the author on StackOverflow back in 2015, who responded he did not use VCL Styles and had no plans on adding the support.

     

    I can attempt to do it. I think most of the work would be in TCustomChromeTabs.DrawCanvas. Unfortunately, I have very little experience writing custom drawing/painting code and no experience implementing VCL Styles in a component.

     

    Can anyone recommend a book or online resource to get my feet wet? :classic_smile:


  13. 4 hours ago, Der schöne Günther said:

    I'd say it absolutely is. You run your editor on any system, and things like inlay hints, code suggestions and compilation itself happens elsewhere. With Delphi/C++ Builder, everything is tied to running locally on a Windows computer.

     

    Or are we focusing exclusively on text editor capabilities? I might have missed that.

    Except you don't run the Delphi IDE on any system. An IDE that is not cross-platform will have limited cross-platform capabilities. Going down that discussion is going off-topic, imo.

     

    That said, I agree that an editor having "front-end" capabilities is a good thing. And some of those may depend on integrating with backend services, such as a LSP server, which may or may not be on the local machine.

    • Like 1

  14. I agree that Undo would be beneficial in the form designer. Saying that, "change history" is one of many benefits of good source control, such as git. I use "Git diff with previous version" quite often with both DFM and PAS files. And DPROJ, for that matter.

     

    I have Beyond Compare installed with Delphi IDE integration. Unfortunately I am not a fan of BC's Delphi integration. It has bit me more than once.


  15. I don't understand the question. On my Windows 11 laptop, TOSVersion.ToString returns

    Windows 11 (Version 22H2, OS Build 22621.2715, 64-bit Edition)

    You could look at TOSVersion.Create in System.SysUtils.pas.

     

    TOSVersion.Name should also return "Windows 11"

    • Like 1

  16. Are wildcards supported in () groups? Is this list valid for MMX?

    Winapi;System.Win;System;Data;Vcl;(hyie*,ie*,imageen*);pp*;Rz*;ra*;vcl.ww*

    Ctrl-Alt-U is moving (hyie*,ie*,imageen*) below everything in the list. My expectation is that my () group is invalid and MMX is ignoring it. Before:

    uses
      Winapi.Windows,
      System.Classes, System.Generics.Collections, System.ImageList, System.SysUtils,
      Data.Win.ADODB,
      Vcl.ActnPopup, Vcl.BaseImageCollection, Vcl.Buttons, Vcl.Controls, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.Forms, Vcl.Graphics,
      Vcl.ImgList, Vcl.Menus, Vcl.PlatformDefaultStyleActnCtrls, Vcl.StdCtrls, Vcl.OleServer, Vcl.VirtualImageList,
      hyiedefs, hyieutils, iemio, iemview, ieview, iesettings, iexBitmaps, iexLayers, iexProcEffects, iexRulers,
      iexToolbars, iexUserInteractions, imageenio, imageenproc, imageenview,
      RzButton, RzCmboBx, RzLabel, RzPanel, RzSplit, RzShellDialogs,
      SVGIconImageCollection, SVGIconImageListBase, SVGIconVirtualImageList,
      OutlookXP, uAisDocument, uUserSettings, udmResources, udmDocResources;

    After:

    uses
      Winapi.Windows,
      System.Classes, System.Generics.Collections, System.ImageList, System.SysUtils,
      Data.Win.ADODB,
      Vcl.ActnPopup, Vcl.BaseImageCollection, Vcl.Buttons, Vcl.Controls, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.Forms, Vcl.Graphics,
      Vcl.ImgList, Vcl.Menus, Vcl.PlatformDefaultStyleActnCtrls, Vcl.StdCtrls, Vcl.OleServer, Vcl.VirtualImageList,
      RzButton, RzCmboBx, RzLabel, RzPanel, RzSplit, RzShellDialogs,
      hyiedefs, hyieutils, iemio, iemview, ieview, iesettings, iexBitmaps, iexLayers, iexProcEffects, iexRulers,
      iexToolbars, iexUserInteractions, imageenio, imageenproc, imageenview, SVGIconImageCollection, SVGIconImageListBase,
      SVGIconVirtualImageList, OutlookXP, uAisDocument, uUserSettings, udmResources, udmDocResources;

     

×