-
Content Count
511 -
Joined
-
Last visited
-
Days Won
6
Posts posted by Tommi Prami
-
-
4 minutes ago, Lars Fosdal said:Did you try with a new .dproj file?
Did not help.
-
Removed all IDE experts, and tried again and it behaves exactly the same...
It seems that I just need to open the inherited form and StyledElements appear right away.
-tee-
-
1 hour ago, Lajos Juhász said:I saw this in Delphi 11.2, whenever I open those files in D12.1 it removes them.
On this project, it is opposite. Or 12.1 patch 1, adds them.
-
https://embt.atlassian.net/servicedesk/customer/portal/1/RSS-779
IDE adds StyledElements default value to inherited form even though not needed
One coworker can't reproduce. So need more info why that might be,
I have few free plugins installed, like GExpers. Have to uninstall those and try if problem is not in the plugins.-Tee-
-
19 hours ago, Anders Melander said:There's one in DWScript: https://github.com/EricGrange/DWScript/blob/c3a26f0e68a5010767681ea1f0cd49726cd4af5d/Source/dwsUtils.pas#L3169
I haven't used it though but knowing Eric, it's probably both fast and well tested. Pity about the 3-space indents though; Very French 🙂
Have to check that out, thanks...
-
5 hours ago, Remy Lebeau said:By definition, a TryXXX() function does not raise an exception into user code. TryISO8601ToDate() is no different.
No it does not, that is OK, but debugger breaks to it anyhow, as it raised in the TryISO8601ToDate, and that is kind of exception I would not like to ignore. IF it would be TryISO8601ToDateException then yes. But generalm date conversion exception I would like to raise my attention.
-tee-
-
17 hours ago, Der schöne Günther said:That is indeed annoying, but we haven't stumbled upon a "real" bug. We are using String/DateTime conversion for Iso8601 from the System.DateUtils all the time.
We had quite a long time own version, because some reported bug, Think there was some reported bug even quite recently.
-Tee-
-
Yellow,
Seems that Delphis own routines are bit flaky. There has been bugs over years. Last problem I had was that TryISO8601ToDate will raise exception on string it can't parse. Will handle/eat the exception but not most optimal solution I think.
By good,m I mean that handle nicely error cases, maybe has more options that Delphi version. Obviously very well tested. If also fast, I wouldn't complain.
-Tee- -
On 4/12/2024 at 5:53 PM, Stefan Glienke said:TValue has no implicit casting rule for integer -> enum - thus it raises the invalid cast exception because you are passing an Integer to SetValue which gets implicit put into a TValue which gets transported further. It later does a type/cast check against the actual type of the property and fails.
See TValue.Cast or TValue.TryCast and the Conversions matrix for more details.
Have to try to remember that. Not used it too much.
Thanks for helping!-Tee-
-
30 minutes ago, Lars Fosdal said:There also is https://docwiki.embarcadero.com/Libraries/Sydney/en/System.TypInfo.GetEnumProp
which returns a PPropInfo, which again contains a PropType: PPTypeInfo, which you then can use with GetEnumValue?
This lead me one step closer.
var LEnumValue: Integer; LEnumValue := GetEnumValue(LProperty.PropertyType.Handle, AValue); if (LEnumValue <> -1) and LProperty.IsWritable then LProperty.SetValue(FInstance, LEnumValue);
With this I get the actual value, but setting the value does not work (More than less same code is used elsewhere and they work).
It raises EInvalidCast with message 'Invalid class typecast'.
Integer is correct value for the Enum, it is in between bounds. This slightly baffles me now.
-
7 minutes ago, msohn said:I've been using TypeInfo.SetEnumProp for that - works for all Enums that are published properties. It basically is SetOrdProp with GetEnumValue shown by Dalija, so saves you figuring out the enum size.
Oh, I forgot to mention that should work public properties also, I modify original, I still can... MAybe it is now more clear what I am after...
-Tee-
-
10 minutes ago, Dalija Prasnikar said:I would use TypeInfo instead of RTTI as it will be faster. This requires System.TypInfo
procedure TMyThingy.SetEnumPropertyValue(const AValue: string); begin PByte(@FEnumProp)^ := GetEnumValue(TypeInfo(TMyEnum), AValue); end;
You should pay attention on enum type size and use appropriate sized pointer when casting PByte(@EnumProp)^. This will also raise out of range exception if passed string does not match to any value in TMyEnum. You can catch that and set it to some default value if needed.
I think I explained myself poorly. That won't work because it depends on TypeInfo(TMyEnum)
My code must not know/depend on the (hardcoded) type, it should be dynamic. Work with any given property, that is any type of Enum (some limitations may apply, but if works simple enums like one in example, it is OK). -
Yellow,
I have about following situation.
FInstance is any TObject descendant and enum property can be any public or published Enum property, code must not link to hard coded enum type.
procedure TMyThingy.SetEnumPropertyValue(const AValue: string); var LContext: TRttiContext; LRtttiType: TRttiType; LProperty: TRttiProperty; begin LContext := TRttiContext.Create; LRtttiType := LContext.GetType(FInstance.ClassType); LProperty := LRtttiType.GetProperty(FPropertyName); // Here I should convert lets say TMyEnum = (A, B, C) from string into the property value // if I call SetEnumPropertyValue('B') property FPropertyName from FInstance-object should be set. end;
This should be quite simple, couple lines of code most likely.
Could not find sample code that was good enough fit to get this to work, there usually was too much knowns, like enum type TMyEnum,
This should be totally dynamic.
Circled around this quite long time, just could not find the way to connect all the dots...-Tee-
-
22 hours ago, Lars Fosdal said:I am afraid so, even if it probably is somewhat outdated by now, in the light of new CPUs.
That might be true, I should have it somewhere. Should read it again. I have only checked few specific things from it.
-
15 minutes ago, Lars Fosdal said:Dang, watching this led me to buy yet another book 🤖
Hackers Delight?
- 1
-
-
13 hours ago, Lars Fosdal said:@Tommi Prami Yes, the installer barfs on restarting the installation due to Navigator, but it should be able to recover. Mine did.
Mine did not.
Restarting encountered into same dll-error, don't remember which dll it was. and did not take screnn shot etc. 😞
Coworker cant open IDE even after clean install... Freezes at the Splash Screen...
-Tee-
-
Remember to uninstall Parnassus-plugins before installing.
Web Installer failed because forgot to uninstall them first. Had to make installer to clean all settings.
Takes some time to get all settings as needed because of that.-Tee-
-
On 3/29/2024 at 9:00 PM, kuzduk said:i already wrote new site address with ssl setificate without antivirus damage!!!!!!!!!!!!!
not use old site adress without ssl with h1n : https://kuzduk.h1n.ru
Moderators, pleace edit first post link to https://kuzduk.ru/delphi/kulibrary
Could you instead of the site update all to the GitHUB, so it would be much easier and better place to public open source library. And keep it up there, and if needed link your own site to the GirHUB and maintain only that actyively.
-Tee-
-
4 minutes ago, Stefan Glienke said:This is nothing new - it's called Eytzinger Layout.
Did not know that. Thanks for info...
-Tee-
-
No idea how it would be done, but for more than less static lookup list etc, this could be very good idea. -
5 minutes ago, Lars Fosdal said:Which again makes me wonder why not
SELECT SUM(Field1) AS Total FROM YourSourceView
but as mentioned, I suspect the example differs from the real world need...
True,
Calculating the sum was just placeholder of some calculation going on in the loop
But very true, if can get sum forehand, would be smart to get it.-Tee-
-
16 hours ago, Sinspin said:What do you mean with "not working"?
The TField fields are not linked to the fields of your query?
When do you try to do the binding?
Btw, FieldByName create already an exception if the FieldName is not found. To prevent that use FindField instead.
As Uwe explained...
-
39 minutes ago, Lars Fosdal said:which doesn't save you that much code, really.
Depends of number of calls and fields. If 8 field 50 places, it would be from 400 -> 50 lines of code. I think it would be significant, Would be net win after first one.
And would make the procedure way more clean, without initialization code in it.
Possible Delphi 12.1 inheritance bug, could someone test also
in VCL
Posted
Interesting...
I'll get back to it when Coworkers has tested that also. Some got the same error on production app, but I'll wait for them to check out the trivial test app also.
-Tee-