Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 12/16/22 in all areas

  1. Saw this today: https://blogs.embarcadero.com/premium-update-subscription-customers-invited-to-join-rad-studio-malawi-beta/ Can someone explain the rationale for putting beta versions of Delphi behind a "premium" subscription, instead of just opening it up to any subscribers who are willing to beta test Delphi? Seems like Delphi needs to find a way to get more testers, not put testing behind a paywall. But maybe I am missing something.
  2. I registered just to thank you for these 2 lines: thank you very much Carsten!! and of course the postcard will also go to Francois :) //the problem mainly occurs under Win11
  3. Yeah, I think you can ignore that answer, it's really not relevant to your question. What you are trying to do is possible by iterating over the node and its children. I would start with some code to do that iteration. Do you have such code?
  4. Dave Nottage

    unable to execute java error

    Please see: https://github.com/DelphiWorlds/HowTo/tree/main/Solutions/AndroidLibraries
  5. Lajos Juhász

    Delphi beta testing a "premium" privilege?

    Why not? It's a priviledge to get access to some kind of "road map information". Their task is also to help to complete the version. This it's premium service of the customers towards the company!
  6. Mark-

    JSON text validation...

    The 10.4 JSON parser uses some newer methods in other units and messing with that is not appealing.
  7. Result: The code was written in D11 but I tried to keep it as simple as possible. I hope D4 supports the below calls... Type TTreeNodes = Array Of TTreeNode; procedure TForm1.Button3Click(Sender: TObject); Var added: TTreeNodes; begin SetLength(added, 0); CopyNodes(Source, Target, added); Target.Expanded := true; end; function TForm1.IsInArray(inTreeNode: TTreeNode; inArray: TTreeNodes): Boolean; Var a: Integer; begin Result := False; For a := 0 To Length(inArray) - 1 Do If inArray[a] = inTreeNode Then Begin Result := True; Exit; End; end; procedure TForm1.CopyNodes(inSource, inDestination: TTreeNode; var inCopied: TTreeNodes); Var a: Integer; tv: TTreeView; tn: TTreeNode; begin tv := inSource.TreeView As TTreeView; For a := 0 To inSource.Count - 1 Do Begin If Not IsInArray(inSource.Item[a], inCopied) Then Begin tn := tv.Items.AddChild(inDestination, inSource.Item[a].Text); // Do data copying, whatever SetLength(inCopied, Length(inCopied) + 1); inCopied[Length(inCopied) - 1] := tn; If inSource.Item[a].Count > 0 Then CopyNodes(inSource.Item[a], tn, inCopied); End; End; end;
  8. programmerdelphi2k

    Copy nodes from a TTreeView with Delphi 4!

    Here, you dont needs a "recursive" function!!! because that if you dont controls it, you know what happens... 🤣 We can use drag-n-drop's "automatic" mode to use less code! Afterwards, we need to know which "node" was selected and dragged, for that we can use two TreeView functions: "GetHitTestInfoAt(X, Y);" and "GetNodeAt(X, Y);" After that, we need to test where the "clicks" occurred in the TreeView; And finally, decide whether we are "Inserting" or "Adding" items to an existing "Node"! However, all this will happen after the "target" accepts or rejects the "Drag-n-drop" action! Here my sample about this situation: you can drag-n-drop in the same TV or to other you free for move to any place on TV: to root or any other level! type TForm1 = class(TForm) TreeView1: TTreeView; procedure TreeView1DragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); procedure TreeView1DragDrop(Sender, Source: TObject; X, Y: Integer); procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); begin TreeView1.DragMode := TDragMode.dmAutomatic; TreeView1.FullExpand; end; procedure TForm1.TreeView1DragDrop(Sender, Source: TObject; X, Y: Integer); var Node : TTreeNode; AttachMode: TNodeAttachMode; HT : THitTests; begin AttachMode := TNodeAttachMode.naAdd; // if TreeView1.Selected = nil then exit; // HT := TreeView1.GetHitTestInfoAt(X, Y); Node := TreeView1.GetNodeAt(X, Y); // if ((HT - [htOnItem, htOnIcon, htNowhere, htOnIndent]) <> HT) then begin if ((htOnItem in HT) or (htOnIcon in HT)) then AttachMode := naAddChild else if (htNowhere in HT) then AttachMode := naAdd else if (htOnIndent in HT) then AttachMode := naInsert; // TreeView1.Selected.MoveTo(Node, AttachMode); // TreeView1.FullExpand; end; end; procedure TForm1.TreeView1DragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); begin Accept := true; end; end.
  9. Here is suggested reading for certification: https://www.embarcaderoacademy.com/courses/delphi-developer-certification-exam/lectures/6312823 I think the last updated exams were in 2011, so these recommended readings are what was available back then. What you already read, some books could be considered advanced, so I think you should be good.
  10. Davide Angeli

    JSON superobject question

    I used JSON superobject for a while and it's good but in cases like this I prefer the very good Delphi NEON library so I could deserialize the JSON directly to Delphi objects. With NEON in a case like yours I could do something like this: Type TVoice = record public Engine : String; VoiceId : String; VoiceGender : String; // .. other fields end; TVoicesData = record public voices_list : TArray<TVoice>; count : Integer; end; TVoices = record public success : Boolean; data : TVoicesData; end; procedure TForm1.Button2Click(Sender: TObject); begin var sJson:= '{'+ ' "success": true,'+ ' "data": {'+ ' "voices_list": ['+ ' {'+ ' "Engine": "neural",'+ ' "VoiceId": "ai2-Stacy",'+ ' "VoiceGender": "Female",'+ ' "VoiceWebname": "Stacy",'+ ' "Country": "US",'+ ' "Language": "en-US",'+ ' "LanguageName": "English, US",'+ ' "VoiceEffects": ['+ ' ]'+ ' },'+ ' {'+ ' "Engine": "neural",'+ ' "VoiceId": "ai1-Matthew",'+ ' "VoiceGender": "Male",'+ ' "VoiceWebname": "Matthew",'+ ' "Country": "US",'+ ' "Language": "en-US",'+ ' "LanguageName": "English, US",'+ ' "VoiceEffects": ['+ ' "news"'+ ' ]'+ ' }'+ ' ],'+ ' "count": 50'+ ' }'+ '}'; var Voices:=DeserializeValueTo<TVoices>(sJson); for var Voice in Voices.data.voices_list do ListBox1.Items.Add(Voice.Engine+' - '+Voice.VoiceGender); end; function TForm1.DeserializeValueTo<T>(const aJSON : String): T; begin if FNeonConfig=Nil then FNeonConfig:=TNeonConfiguration.Default; var LJSON := TJSONObject.ParseJSONValue(aJSON); try var LReader:=TNeonDeserializerJSON.Create(FNeonConfig); try var LValue:=LReader.JSONToTValue(LJSON, TRttiUtils.Context.GetType(TypeInfo(T))); Result:=LValue.AsType<T>; finally LReader.Free; end; finally LJSON.Free; end; end;
  11. Remy Lebeau

    Json create Array

    In the JSON you want to create, "registration_ids" is an array of strings. But in your code, you are creating "registration_ids" as an array of objects instead. To get the result you want, between WriteStartArray() and WriteEndOfArray(), you need to get rid of WriteStartObject(), WritePropertyName(''), and WriteEndObject(): wrtString := TStringWriter.Create(); wrtJSON := TJsonTextWriter.Create(wrtString); try wrtJSON.Formatting := TJsonFormatting.Indented; wrtJson.WriteStartObject; wrtJson.WritePropertyName('registration_ids'); wrtJson.WriteStartArray; //wrtJson.WriteStartObject; // <-- //wrtJson.WritePropertyName(''); // <-- wrtJson.WriteValue(strToken); //wrtJson.WriteEndObject; // <-- wrtJson.WriteEndArray; wrtJson.WritePropertyName('notification'); wrtJSON.WriteStartObject; wrtJSon.WritePropertyName('title'); wrtJson.WriteValue(edtBaslik.Text); wrtJson.WritePropertyName('body'); wrtJson.WriteValue(edtMesaj.Text); wrtJSON.WriteEndObject; wrtJSON.WriteEndObject; That said, why are you using TJsonTextWriter at all? This would be much more straight-forward if you used TJSONObject and TJSONArray instead, eg: uses ..., System.JSON; var arr: TJSONArray; notif, obj: TJSONObject; strJSON: string; begin obj := TJSONObject.Create; try arr := TJSONArray.Create; try arr.Add(strToken); obj.AddPair('registration_ids', arr); except arr.Free; raise; end; notif := TJSONObject.Create; try notif.AddPair('title', 'Hi'); notif.AddPair('body', 'Notification test'); obj.AddPair('notification', notif); except notif.Free; raise; end; strJSON := obj.ToJSON; // or, obj.Format finally obj.Free; end; // use strJSON as needed... end;
  12. Attila Kovacs

    Delphi 11.1 + patches - No debug source / breakpoints?

    I tried to look up this for you and as I changed the remote debugging settings it screwed up my custom Version info what I'm using for building the database connection so I had to restore the dproj from a backup as I could not get it work again. You are on your own now.
×