Jump to content

Lars Fosdal

Administrators
  • Content Count

    3416
  • Joined

  • Last visited

  • Days Won

    113

Everything posted by Lars Fosdal

  1. Lars Fosdal

    Are we just "Cash Cows"?

    Unless substantiated, this is just FUD.
  2. Lars Fosdal

    Are we just "Cash Cows"?

    Can you substantiate this claim?
  3. Lars Fosdal

    Parsing JSON response from TVDB

    A matter of taste. I don't mind RTTI and we use it extensively in all our apps.
  4. Lars Fosdal

    Parsing JSON response from TVDB

    std := TJson.JsonToObject<TStDiscovery>(YourJsonStringHere);
  5. Lars Fosdal

    Are we just "Cash Cows"?

    Still on 10.3.3 with all its quirks and instabilities, since 10.4 is unusable to me. I try to focus on writing code while I curse at the unstable IDE and debugger. Since I depend on EMBT fixing those issues, at least my subscription renewal increases the chance that there will be funds to do that fixing. Other than that, I refrain from speculations on corporate strategies since they are well and truly outside my control.
  6. Lars Fosdal

    Parsing JSON response from TVDB

    First, remove the comment at the top of the stdiscovery.json file. Comments are not valid in Json. Save this as Json type unit: StJsonTypes.pas Caveat: I assumed that fields with value NULL are Integer fields. Since we don't have nullables, an Integer NULL becomes, you guessed it: 0. unit StJsonTypes; interface uses System.Classes, System.SysUtils; type TLinks = class(TObject) private Flast: Integer; Fprev: Integer; Ffirst: Integer; Fnext: Integer; public property first: Integer read Ffirst write Ffirst; property last: Integer read Flast write Flast; property next: Integer read Fnext write Fnext; property prev: Integer read Fprev write Fprev; end; TLang = class (TObject) private FepisodeName: string; Foverview: string; public property episodeName: string read FepisodeName write FepisodeName; property overview: string read Foverview write Foverview; end; TData = class (TObject) private Flanguage: TLang; FairsAfterSeason: Integer; Ffilename: string; FEpisodeName: string; FlastUpdatedBy: Integer; FdvdChapter: Integer; FthumbHeight: string; FairsBeforeEpisode: Integer; FdvdSeason: Integer; FthumbAdded: TDateTime; FdvdEpisodeNumber: Integer; FcontentRating: string; FthumbAuthor: Integer; FlastUpdated: Integer; Foverview: string; Fdirectors: TArray<String>; FairedSeason: Integer; FabsoluteNumber: Integer; FisMovie: Integer; Fwriters: TArray<String>; Fid: Integer; FairedEpisodeNumber: Integer; FthumbWidth: string; FairsBeforeSeason: Integer; FdvdDiscid: string; FshowUrl: string; FsiteRating: Double; FseriesId: Integer; FproductionCode: string; FfirstAired: TDateTime; FguestStars: TArray<String>; FairedSeasonID: Integer; FsiteRatingCount: Integer; public property id: Integer read Fid write Fid; property airedSeason: Integer read FairedSeason write FairedSeason; property airedSeasonID: Integer read FairedSeasonID write FairedSeasonID; property airedEpisodeNumber: Integer read FairedEpisodeNumber write FairedEpisodeNumber; property episodeName: string read FEpisodeName write FepisodeName; property firstAired: TDateTime read FfirstAired write FfirstAired; property guestStars: TArray<String> read FguestStars write FguestStars; property directors: TArray<String> read Fdirectors write Fdirectors; property writers: TArray<String> read Fwriters write Fwriters; property overview: string read Foverview write Foverview; property language: TLang read Flanguage write FLanguage; property productionCode: string read FproductionCode write FproductionCode; property showUrl: string read FshowUrl write FshowUrl; property lastUpdated: Integer read FlastUpdated write FlastUpdated; property dvdDiscid: string read FdvdDiscid write FdvdDiscid; property dvdSeason: Integer read FdvdSeason write FdvdSeason; property dvdEpisodeNumber: Integer read FdvdEpisodeNumber write FdvdEpisodeNumber; property dvdChapter: Integer read FdvdChapter write FdvdChapter; property absoluteNumber: Integer read FabsoluteNumber write FabsoluteNumber; property filename: string read Ffilename write Ffilename; property seriesId: Integer read FseriesId write FseriesId; property lastUpdatedBy: Integer read FlastUpdatedBy write FlastUpdatedBy; property airsAfterSeason: Integer read FairsAfterSeason write FairsAfterSeason; property airsBeforeSeason: Integer read FairsBeforeSeason write FairsBeforeSeason; property airsBeforeEpisode: Integer read FairsBeforeEpisode write FairsBeforeEpisode; property imdbId: string read FcontentRating write FcontentRating; property contentRating: string read FcontentRating write FcontentRating; property thumbAuthor: Integer read FthumbAuthor write FthumbAuthor; property thumbAdded: TDateTime read FthumbAdded write FthumbAdded; property thumbWidth: string read FthumbWidth write FthumbWidth; property thumbHeight: string read FthumbHeight write FthumbHeight; property siteRating: Double read FsiteRating write FsiteRating; property siteRatingCount: Integer read FsiteRatingCount write FsiteRatingCount; property isMovie: Integer read FisMovie write FisMovie; constructor Create; destructor Destroy; override; procedure Dump; end; TstDiscovery = class(TObject) private Flinks: TLinks; Fdata: TArray<TData>; public property links: TLinks read Flinks write Flinks; property data: TArray<TData> read Fdata write Fdata; constructor Create; destructor Destroy; override; end; implementation { TData } constructor TData.Create; begin Flanguage := TLang.Create; end; destructor TData.Destroy; begin Flanguage.Free; inherited; end; procedure TData.Dump; begin Writeln('id:', id, ' episodeName: ', episodeName); Writeln('filename: ', filename); Writeln('firstAired: ', FormatDateTime('yyyy.mm.dd', firstAired)); Writeln; end; { TstDiscovery } constructor TstDiscovery.Create; begin FLinks := TLinks.Create; end; destructor TstDiscovery.Destroy; var d: TData; begin FLinks.Free; for d in data do d.free; inherited; end; end. Save this as 'TestStDirectory.dpr' - Correct the FileDir constant to point to where you have the StDirectory.json file. program TestStDirectory; {$APPTYPE CONSOLE} {$R *.res} uses System.Classes, System.SysUtils, System.RTTI, REST.Json, StJsonTypes in 'StJsonTypes.pas'; procedure TestStDiscovery; var FileDir: string; std: TStDiscovery; d: TData; f: TStringList; begin FileDir := 'D:\temp\Downloads\'; f := TStringList.Create; std := nil; try Writeln('Reading file'); // Make sure to remove the // comment from the .json file - Comments are not legal in Json f.LoadFromFile(FileDir + 'stdiscovery.json', TEncoding.utf8); Writeln('Create StDiscovery object from Json'); std := TJson.JsonToObject<TStDiscovery>(f.Text); Writeln(Length(std.data), ' elements found'); for d in std.data do d.Dump; Writeln('Converting object back to Json'); f.Text := TJson.ObjectToJsonString(std, [joIgnoreEmptyStrings, joIgnoreEmptyArrays, joDateIsUTC, joDateFormatISO8601]); Writeln('Saving Json to file'); f.SaveToFile(FileDir + 'stdiscovery_recreated.json', TEncoding.utf8); Writeln('Done'); finally f.Free; std.Free; end; end; begin try try TestStDiscovery; except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; finally Write('Press Enter: '); Readln; end; end. Output: Reading file Create StDiscovery object from Json 17 elements found id:6143085 episodeName: The Vulcan Hello filename: episodes/328711/6143085.jpg firstAired: 2017.09.24 id:6143290 episodeName: Battle at the Binary Stars filename: episodes/328711/6143290.jpg firstAired: 2017.09.24 id:6321258 episodeName: Context Is for Kings filename: episodes/328711/6321258.jpg firstAired: 2017.10.01 id:6321259 episodeName: The Butcher's Knife Cares Not for the Lamb's Cry filename: episodes/328711/6321259.jpg firstAired: 2017.10.08 id:6353529 episodeName: Choose Your Pain filename: episodes/328711/6353529.jpg firstAired: 2017.10.15 id:6353530 episodeName: Lethe filename: episodes/328711/6353530.jpg firstAired: 2017.10.22 id:6362450 episodeName: Magic to Make the Sanest Man Go Mad filename: episodes/328711/6362450.jpg firstAired: 2017.10.29 id:6362451 episodeName: Si Vis Pacem, Para Bellum filename: episodes/328711/6362451.jpg firstAired: 2017.11.05 id:6362452 episodeName: Into the Forest I Go filename: episodes/328711/6362452.jpg firstAired: 2017.11.12 id:6402864 episodeName: Despite Yourself filename: episodes/328711/6402864.jpg firstAired: 2018.01.07 id:6452568 episodeName: The Wolf Inside filename: episodes/328711/6452568.jpg firstAired: 2018.01.14 id:6452569 episodeName: Vaulting Ambition filename: episodes/328711/6452569.jpg firstAired: 2018.01.21 id:6452570 episodeName: What's Past is Prologue filename: episodes/328711/6452570.jpg firstAired: 2018.01.28 id:6452571 episodeName: The War Without, the War Within filename: episodes/328711/6452571.jpg firstAired: 2018.02.04 id:6452573 episodeName: Will You Take My Hand? filename: episodes/328711/6452573.jpg firstAired: 2018.02.11 id:6854213 episodeName: Brother filename: episodes/328711/6854213.jpg firstAired: 2019.01.17 id:6903811 episodeName: "Will You Take My Hand?" Bonus Scene filename: episodes/328711/6903811.jpg firstAired: 2018.03.25 Converting object back to Json Saving Json to file Done Press Enter:
  7. Lars Fosdal

    Open Type Arrays?

    I am trying to see a proper use case for this, as the example is too simplistic to make sense. What is the problem that needs to be solved? What is the duplicate work that needs to be eliminated?
  8. Lars Fosdal

    Your RAD Studio 10.4 Sydney issues

    Feel free to post a QP link to issues that cause you problems in 10.4 and that you think that other users need to be aware of. For things you love about the new version, see this thread! You can also vote on your current experience here
  9. Lars Fosdal

    Sample for TWaitFor (or something similar)

    IMO, minimizing or avoiding Synchronize is preferable.
  10. But isn't everything moving towards 64-bit?
  11. Lars Fosdal

    How to increase the distance between TCheckBox glyph and caption text?

    There are numerous Unicode white space chars of varying width, so adjusting the distance "by character" is possible.
  12. @David Heffernan - At this point in time, would it make sense to ask EMBT to focus primarily on the 64-bit part of this?
  13. Lars Fosdal

    Sample for TWaitFor (or something similar)

    Use a worker thread which stays active and take tasks through a queue.
  14. Off-topic for this thread, isn't it?
  15. Lars Fosdal

    How to increase the distance between TCheckBox glyph and caption text?

    Well, what do you know! I actually didn't know you could wordwrap a checkbox caption! Thanks, @Attila Kovacs!
  16. Having these discussions on desired language features bear little effect unless a properly thought through and well written proposal is submitted through QP, and even then it is just a pipe dream until it gathers a large number of votes, and/or someone within EMBT agrees that it is a good idea. Keep the ideas coming, and do discuss them - but unless they are formally submitted, we are just having a chat by the watercooler, if you see the analogy?
  17. Lars Fosdal

    Sample for TWaitFor (or something similar)

    COM objects will work in a sub-thread if they are created after calling WinAPI.ActiveX.CoInitialize(nil) and destroyed before calling WinAPI.ActiveX.CoUnintialize, in that thread.
  18. @David Heffernan - I took the liberty of splitting this off into a new thread. I think @Marco Cantu and @David Millington should look closer at this.
  19. Lars Fosdal

    Ctrl Tab Ide Plugin

    What happened to that document? https://web.archive.org/web/20171221023547/http://qc.embarcadero.com/wc/qcmain.aspx?d=107411 Edit: I took the liberty of splitting David's answer into a new thread.
  20. Lars Fosdal

    Where to put SQLite/MDB database in UWP app

    Different part - as in Outside the sand box - but it seems the file system is fully virtualized. A bit odd that you cannot specify %APPDATA% in the deployment system, since that actually is the appropriate path. Write under AppData Windows 10, version 1903 and later: New files and folders created under the following directories are redirected to a per-user, per-package private location: Local Local\Microsoft Roaming Roaming\Microsoft Roaming\Microsoft\Windows\Start Menu\Programs In response to a file open command, the OS will open the file from the per-user, per-package location first. If this location doesn't exist, the OS will attempt to open the file from the real AppData location. If the file is opened from the real AppData location, no virtualization for that file occurs. File deletes under AppData are allowed if user has permissions. Windows 10, version 1809 and earlier: Copy-on-written to a per-user, per-app location. AppData is typically C:\Users\user_name\AppData.
  21. Lars Fosdal

    Where to put SQLite/MDB database in UWP app

    On the other hand, APPX apps are supposed to be sandboxed - hence moving a file to a different part of the system might not be a good idea? I could be wrong about this, though.
  22. Lars Fosdal

    Where to put SQLite/MDB database in UWP app

    Which looks like a shared folder - unless that part on the end is a user specific key. If you install it with a different user - is a new folder C:\Program Files\WindowsApps\MYAPPNAME_1.0.0.0_x86__?????? created, or is the same folder used? Looking at http://docwiki.embarcadero.com/RADStudio/Sydney/en/Deployment_Manager, all the examples simply uses .\ - so perhaps that is sufficient.
  23. Lars Fosdal

    Where to put SQLite/MDB database in UWP app

    If you name it .\YourAppFolder\ Where is that folder created in the current user's file system?
  24. Lars Fosdal

    Where to put SQLite/MDB database in UWP app

    Where is that folder created? When it creates a folder named %APPDATA% - Where does it create it? C:\users\username\%APPDATA% ? C:\%APPDATA% ? Where is it created?
  25. Lars Fosdal

    Where to put SQLite/MDB database in UWP app

    Is the DB supposed to specific for the current user, or do you want a single DB for all users on the machine?
×