Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 03/29/23 in all areas

  1. /off-topic Me: I need help defusing a bomb AI: What kind of bomb Me: posts a series of photos of the bomb AI: Cut the red wire ... *BOOM* AI: ... after cutting the green wire
  2. Think of it as embedded = portable ( no need to install, just make the binaries available ). Remember as well you are loading python into Delphi which does not have c runtime. C runtime might be required by some python modules. python -m pip install msvc_runtime This is the layout I use and it works correctly. My python install procedure copies c runtime to the EXE folder so that it loads it on the path.
  3. @KoRiFIndeed, that is exactly the case. Python and all required libraries come together with the executable in an associated folder "3.10". In my understanding this folder "3.10" (in my case) must be copied to the same directory as of the Delphi executable in the target machine, although "PyEmbedded" hints me to having it all inside the executable. Might still be possible, I hope. Anyway, there is no need to install Python on the target machine. Moreover, it works like a charm!
  4. Anders Melander

    Anyone know why?

    Why? I haven't seen my client or the rest of my team for something like 4 years. They're in Norway, btw. The webcam on my main PC broke 3 years ago, so most of the team has literally never seen me. The others think I have short hair and am clean-shaven, but I stopped shaving and cutting my hair when Corona hit, so they wouldn't even recognize me now with a full beard and a ponytail. I've previously worked with teams in Ukraine, Sweden, and the UK that I never met physically and never had any practical need to meet. Sure, it's nice to get together for pizza and beer once in a while, but that's just a nice-to, not a need-to.
  5. Anders Melander

    Interface Reference counting

    Yes: Don't be lazy. This is the better approach: Don't use Assigned() unless you have a reason to. Assigned() just adds another layer that your brain has to parse. Testing against nil makes it immediately clear what's going on. Yes. Yes and no. Since the MyObject parameter is a value parameter you're not returning anything (besides the boolean). And since you're not returning a reference to the interface the ref count will become 0 when the method returns and the object will be destroyed. The debugger would have shown you this if you'd tried it.
  6. interface uses REST.JsonReflect, System.RTTI; type TSuppressZeroDateInterceptor = class(TJSONInterceptor) public function StringConverter(Data: TObject; Field: string): string; override; procedure StringReverter(Data: TObject; Field: string; Arg: string); override; end; SuppressZeroDateAttribute = class(JsonReflectAttribute) public constructor Create; end; implementation { TSuppressZeroDateInterceptor } function TSuppressZeroDateInterceptor.StringConverter(Data: TObject; Field: string): string; var ctx: TRTTIContext; date: TDateTime; begin date := ctx.GetType(Data.ClassType).GetField(Field).GetValue(Data).AsType<TDateTime>; if date <= 1.0 then begin result := EmptyStr; end else begin result := DateToISO8601(date, True); end; end; procedure TSuppressZeroDateInterceptor.StringReverter(Data: TObject; Field, Arg: string); var ctx: TRTTIContext; date: TDateTime; begin if Arg.IsEmpty then begin date := 0; end else begin date := ISO8601ToDate(Arg, True); end; ctx.GetType(Data.ClassType).GetField(Field).SetValue(Data, date); end; { SuppressZeroDateAttribute } constructor SuppressZeroDateAttribute.Create; begin inherited Create(ctString, rtString, TSuppressZeroDateInterceptor); end; A trick I learned from @Uwe Raabe : Add the above code somewhere. In your class that emits Json, add the SuppressZeroDate attribute before the Field of the property. TMyClass = class private [SuppressZeroDate] FDate: TDateTime public property Date: TDateTime read FDate write FDate; end;
  7. Anders Melander

    Choosing a Mac

  8. Anders Melander

    Dealing with multiple component versions using the same ide

    Here you go: https://bitbucket.org/anders_melander/delphilauncher/src/main/ The following was copy/pasted from the repo readme.md so the formatting is a bit messed up: 1) Create a folder to hold the environment. > DelphiLauncher\MyProject We call this the environment root folder. 2) Create a folder named Packages under the environment root folder. > DelphiLauncher\MyProject\Packages We call this the package folder. 3) Export the content of the HKEY_CURRENT_USER\Software\Embarcadero\BDS\<version>\Known Packages registry key to a reg file named packages.reg in the environment root folder. <version> denotes the version of Delphi. For example 20.0 for Delphi 10.3 4) Rename packages.reg to packages.txt > DelphiLauncher\MyProject\packages.txt 5) Edit packages.txt Remove the first 3 lines of the file so the file only contains the package list. 6) For all the design-time packages in the list and all the run-time packages they depend on, copy the files to sub-folders 1 of the package folder. > DelphiLauncher\MyProject\Packages\Graphics32\GR32_DD110.bpl > DelphiLauncher\MyProject\Packages\Graphics32\GR32_RD110.bpl > DelphiLauncher\MyProject\Packages\DevExpress\dcldxRibbonRS28.bpl etc 7) Zip the content of the package folder into a file named packages.zip in the environment root folder. > DelphiLauncher\MyProject\packages.zip The package folder can now be deleted. The folder and its content will be recreated by the script on demand. 😎 Add the packages.txt file to packages.zip. The packages.txt file can now be deleted. The file will be recreated by the script on demand. 9) Create a text file named environment.ini in the environment root folder. > DelphiLauncher\MyProject\environment.ini The file is an ini-file with the following content: [environment] delphi=<version> project=<name> revision=<value> where <version> is the version of Delphi used. It must match the value of <version> mentioned in step 3. > delphi=20.0 <name> is the name of the environment. > project=My project The value is displayed in the Delphi title bar. <value> is the environment revision number/id. > revision=1 The combination of <name><value> is used to detect if the environment has been updated and should be refreshed. If you change, add, or remove any package files, one or both of <name> and <value> must be changed. Typically only <value> is changed. 10) Copy the start.ps1 script from another environment into the environment root folder. > DelphiLauncher\MyProject\start.ps1 Note: Packages that are listed in packages.txt but do not exist on disk are ignored. Packages located in $(BDSBIN) are assumed to be Delphi's own and are left as-is. The paths in packages.txt are ignored. Only the file names are significant. It's a good idea to place a text file named versions.txt in the environment root folder that contains the name and version numbers of the libraries contained in the package sub-folders. This makes it easier to determine what an environment contains. > DevExpress 2022.1.3.0 > TeeChart 9.0.26.0 > madExcept 5.1.2 (madCollection 2.8.11.7) If the project will be used with several different versions of Delphi, just create an environment root folder for each version. > DelphiLauncher\MyProject\Delphi 10.3 DelphiLauncher\MyProject\Delphi 11.0 Revision control The following files define an environment and can be placed under revision control (e.g. checked into a Git repository): start.ps1 environment.ini packages.zip versions.txt (optional) All other files are transitory and can be ignored. For Git it might be a good idea to enable LFS for zip files on the repository if the file is large. YMMV. The names of the sub-folders are not important. The sub-folders are only used to better organize the files. ↩
  9. Dave Craggs

    StacTrace

    OK got it working. Needed to include {$I DUnitX.Stacktrace.inc} Needed to be edited to enable MadExcept5 Also needed to add DUnitX.StackTrace.MadExcept5 to the project.
  10. Dave Nottage

    Multiplatform Hello World error [PAClient Error] Error: E7688

    Looks like you may be using a project created with an older version of Delphi. Please refer to: https://github.com/DelphiWorlds/HowTo/tree/main/Solutions/AndroidLibraries
×