Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 11/24/22 in all areas

  1. Dear Delphi Developers! We have Time-Limited offer from Almediadev and DelphiStyles! You can order components and styles with good discount now! https://www.almdev.com/order.html https://www.delphistyles.com/order.html Regards, Almediadev
  2. Angus Robertson

    8.66 installation for D2007 problems

    Sorry, VCLZipPack seems to slipped back into OverbyteIcsD2007Run.dpr/dproj with the changes to remove it in V8.70 from more recent compilers. Just remove it and the package should rebuild, You may have to also fix a missing variable in another old unit. I've now disabled VclZip from my master copy since I'm no longer using it now ICS supports TZipFile, so this should not happen again... These changes are now in SVN. Angus
  3. Hello John, I've tried your code but I get some side effects like black rows, bad row separators and wrong scrollbars: Do you have any improved version? Thank you very much in advance. Regards, Jaroslaw
  4. 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;
  5. David Schwartz

    Function with 2 return values ?

    You can override the counter method to disable it, right?
  6. Attila Kovacs

    IsZero or SameValue

    match, matcher, matchest? The tolerance determines the result, isn't it?
  7. Dave Nottage

    Stacking FMX components over native elements

    Actually, it probably will. I already overlay things like TMapView and TWebBrowser, using the "native" controls in the Kastri repo: https://github.com/DelphiWorlds/Kastri/blob/master/Controls/NativeControls.md. The part that's missing is macOS support.
  8. Fr0sT.Brutal

    IsZero or SameValue

    Comparing with tolerance is the only way of comparing floats isn't it? I wrote a little test procedure RunCompare(Epsilon: Double); const Base: Double = 0.1; var i: Integer; res: Double; begin res := 0; for i := 0 to MaxInt do begin if CompareValue(res, Base*i, Epsilon) <> EqualsValue then begin WriteLn( Format('Epsilon is %.17f: deviation at step %d', [Epsilon, i]) ); Exit; end; res := res + Base; end; end; procedure TestCompare; var i: Integer; EpsilonDiv: Int64; begin RunCompare(0); EpsilonDiv := Trunc(10E16); for i := 0 to 16 do begin RunCompare(1/EpsilonDiv); EpsilonDiv := EpsilonDiv div 10; end; end; it outputs Epsilon is 0,00000000000000000: deviation at step 8 Epsilon is 0,00000000000000001: deviation at step 3 Epsilon is 0,00000000000000010: deviation at step 8 Epsilon is 0,00000000000000100: deviation at step 29 Epsilon is 0,00000000000001000: deviation at step 73 Epsilon is 0,00000000000010000: deviation at step 262 Epsilon is 0,00000000000100000: deviation at step 928 Epsilon is 0,00000000001000000: deviation at step 2512 Epsilon is 0,00000000010000000: deviation at step 7415 Epsilon is 0,00000000100000000: deviation at step 23039 Epsilon is 0,00000001000000000: deviation at step 75679 Epsilon is 0,00000010000000000: deviation at step 261471 Epsilon is 0,00000100000000000: deviation at step 942813 Epsilon is 0,00001000000000000: deviation at step 2489005 Epsilon is 0,00010000000000000: deviation at step 7379011 Epsilon is 0,00100000000000000: deviation at step 23073610 Epsilon is 0,01000000000000000: deviation at step 76188297 Epsilon is 0,10000000000000001: deviation at step 264487878 0 is the value auto-calculated from both operands. As you can see, this epsilon starts to fail already after 8th step. So it seems one should provide explicit sane Epsilon for each Same|CompareValue call to be sure the desired result is achieved
×