-
Content Count
3416 -
Joined
-
Last visited
-
Days Won
113
Everything posted by Lars Fosdal
-
Low(Integer) - assuming 32-bit Integer - will always be -2,147,483,648 What value were you expecting to see? Zero? Then you need to use Default 0 - or type Cardinal instead of Integer. Note that using a Cardinal can introduce challenges with regards to math operations that may cause a signed result such as (Small.Minvalue - Big.MinValue) < 0
-
My preferred way of dealing with sub-tasks is to provide a "mailbox" i.e. some sort of container, like a queue, array or list, for them to insert their results in. The main thread can either poll the mailbox periodically, or you could use a message or signal to initiate the polling whenever the container has content added.
-
Cross-platform solution to forcefully end a thread
Lars Fosdal replied to aehimself's topic in Cross-platform
Our servers rarely run with less than 25 concurrent threads. We also have threads that can't run in parallel and a scheduler in place that ensures that it doesn't happen. Have we had problems? Sure, when we broke the rules. Threads are not more dangerous or hard to use than any other field of development you are introduced to. The hardest thing about multithreading is to adapt your thinking to asynchronous events, instead of sequences. -
is there any "currency to words" routine for Delphi?
Lars Fosdal replied to Attila Kovacs's topic in Algorithms, Data Structures and Class Design
It seems that the French has a "times 20" system that is somewhat similar to the Danes. -
For my last questions - I was wondering whether removing a beacon from the manager, or stopping/starting the manager helped for redetecting the first detected beacon?
-
What is the format of the text message itself, i.e. not the attachment, but the body of text? If HTML - does it contain: <meta charset="UTF-8"> If XML - does it contain: <?xml version = "1.0" encoding = "UTF-8" ?> If plain string - Do you explicitly transform the string from the internal unicode string to UTF-8? I also stumbled on this: https://stackoverflow.com/questions/40469867/message-rfc822-ignores-utf-8 See last comment by @Remy Lebeau
-
My guess: String encoding. Explicitly setting to UTF-8 wherever possible should cure it?
-
Your client connection needs to set up SSL correctly to be able to connect to an SSL enabled SQL Server. The driver installation is done on the client-side.
-
A small self-contained compilable example would be helpful, I guess?
-
is there any "currency to words" routine for Delphi?
Lars Fosdal replied to Attila Kovacs's topic in Algorithms, Data Structures and Class Design
@Dany Marmur - I'm not a Dane, so it may be that the "seksti" / sixty is purely Norwegian. The standing Norwegian joke about the Danish language is that it is not a language, but a throat disease 😛 That said, Norwegian was under Danish rule for hundreds of years, so the languages are quite close in structure as well as vocabulary. Norwegian is "harder" / "crisper" in pronunciation, though - unless you consider the south-most dialects, neighboring Denmark 🙂 -
Cross-platform solution to forcefully end a thread
Lars Fosdal replied to aehimself's topic in Cross-platform
Threads are dangerous in the same way that travel by car is dangerous. If you prepare well, know how to drive, follow the rules and take the appropriate precautions, then you will be in control and nothing bad happens. As always, there may be external factors that can cause problems - but that goes for code that is not executed in threads as well. That said - in this case, it sounds like the third party engine has serious flaws. -
Cross-platform solution to forcefully end a thread
Lars Fosdal replied to aehimself's topic in Cross-platform
I am not sufficiently versed in Android and iOS to suggest a workaround there, but for Linux, you could write a thin wrapper executable and fork to run it. If it doesn't complete within a reasonable time, you can kill that process. On Android and iOS I guess forking would require permissions of some sort? -
Cross-platform solution to forcefully end a thread
Lars Fosdal replied to aehimself's topic in Cross-platform
DLL = Windows only. -
Cross-platform solution to forcefully end a thread
Lars Fosdal replied to aehimself's topic in Cross-platform
There doesn't seem to be a similar cross platform function. What is wrong with Thread.Terminate? You can override SetTerminate to set your own variables on termination. F.x. if you don't want to have a Terminated check in a tight loop, you could nil a variable you reference in the loop to raise an exception to get out of that loop. Ugly, yes - but not much uglier than TerminateThread. -
Firstly, I highly recommend using the new MSSQLODBC Driver 17, or the SQLNCLI 11 diver over the default one. https://docs.microsoft.com/en-us/sql/connect/odbc/windows/microsoft-odbc-driver-for-sql-server-on-windows?redirectedfrom=MSDN&view=sql-server-ver15 What generation is the SQL Server? 2008? 2012? 2016? 2017? 2019? What did you do to set up the SSL support on the client side? This article outlines the steps needed. https://techdocs.broadcom.com/content/broadcom/techdocs/us/en/ca-enterprise-software/layer7-identity-and-access-management/single-sign-on/12-52-02/configuring/policy-server-configuration/user-directories/configure-a-microsoft-sql-server-database-connection-over-ssl.html
-
I guess you have read http://docwiki.embarcadero.com/RADStudio/Rio/en/Using_Beacons#Scanning_for_Beacons John? I've not used beacons myself, but I suspect we will evaluate them sometime next year, so I am curious to learn. What do you do with the beacon once you detect it? What happens if you remove it from the Beacon manager? What happens if your stop/start monitoring?
-
is there any "currency to words" routine for Delphi?
Lars Fosdal replied to Attila Kovacs's topic in Algorithms, Data Structures and Class Design
You could also say that the half indicates a half twenty. half tres = 2.5 x 20 = 50 half firs = 3.5 x 20 = 70 half fems = 4.5 x 20 = 90 It is logical, but to a foreigner it does feel a bit jumbled - and why isn't there two twenty somethings like, 1.5 x 20 = 30, and 2 x 20 = 40? -
is there any "currency to words" routine for Delphi?
Lars Fosdal replied to Attila Kovacs's topic in Algorithms, Data Structures and Class Design
Just to illustrate the complexity of this in a different language, look at the danes that work with n times 20s and half-20s when above 50 and below 100, and they are not entirely consistent about it either. I am not a native dane, so there may be some mistakes - but this is my understanding of their classic spoken numbering. førr = forty = 40 fem og førr = five and forty = 45 half tres / femti = fifty = 3 x 20 - 10 = 50 seks og halv tres = six and fifty = 6 + (3 x 20 - 10) = 56 seksti / tres = sixty = 3 x 20 = 60 fem og seksti = five and sixty = 65 half firs / søtti = seventy = 4 x 20 - 10 = 70 åtti / firs = eighty = 4 x 20 = 80 half fems / nitti = ninety = 5 x 20 - 10 = 90 syv og halv fems = seven and ninety = 97 hundrede / fems = hundred = 5 x 20 = 100 277 = to hundrede og syv og halv firs = two hundred and seven and seventy = 200 + 7 + 70 Modern Danish does allow saying 55 = "femti fem" instead of "fem og halv tres" - i.e. more like the English spoken "fifty five", but the classic form is widely used. Modern 277 would be "to hundrede og søtti syv", like the English "two hundred and seventy seven". -
How to manage defined list values
Lars Fosdal replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
Come to think of it, it could have been nice to be able to enforce the helper implementations with an interface. or even better, be able to reuse an interface implementation for handling attribute naming. Also, this: /SendsLetterToCompilerSanta -
How to manage defined list values
Lars Fosdal replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
There is no definitive answer to that as YMMV. We do literally have 100+ types of enums, and we implemented record helpers for each one, simply to ensure that all enums had the same capabilities. AsString, FromString, Name, and in some cases more texts, or biz.logic associated with the enum. We actually did the last push for this model this autumn, to get rid of the last couple of dozens of standalone TypeNameToStr functions. We also introduced app wide translations (Norwegian, Swedish, English) using Sisulizer. It turned out that using attributes for naming was a bit of a challenge, since you can't use a resourcestring as an argument to an attribute - go figure. resourcestring sName = 'Name'; type AttrNameAttribute = class(TCustomAttribute) constructor Create(const aName: String); end; type TSomeType = class private FaName: string; procedure SetaName(const Value: string); public [AttrName(sName)] // <-- [dcc32 Error] : E2026 Constant expression expected property aName: string read FaName write SetaName; end; We ended up setting names explicitly in code instead. -
How to manage defined list values
Lars Fosdal replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
How do you associate the string attribute(s) with each enum value? -
How to manage defined list values
Lars Fosdal replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
InitHelper initializes the class var arrays for Caption and DevTitle (for the second example using class vars). You only need to call this once for the application, so you could do f.x. it in the unit init section. For your second question, see the implementation of TProjectTypeHelper.Caption. Why the extra class function CaptionOf? A habit of mine, due to the rule of only one class helper for a type in scope at a time. -
How to manage defined list values
Lars Fosdal replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
@David Heffernan - Do you scan the rtti attributes once in a class init method/first use, or do you fetch the attributes at each use? -
How to manage defined list values
Lars Fosdal replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
For the latter example: begin TProjectType.InitHelper; var prj: TProjectType := ptExternalDev; Writeln(prj.Caption); end; will output External Dev Project -
How to manage defined list values
Lars Fosdal replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
Both. See updated post. Let me correct myself... With a record helper, the methods of the helper become part of the helped type. begin TProjectType.InitClass; // only for the second example var prj: TProjectType = ptMain; writeln(prj.Caption); writeln(ptMain.Caption) writeln(TProjectType.CaptionOf(ptMain)) end; all output the same string. Populating a combobox can be done like this for var prj := Low(TProjectType) to High(TProjectType) do ComboBox1.AddItem(prj.Caption, Pointer(Ord(prj))); and later, if you like such ugly hacks 😉 if ComboBox1.ItemIndex >= 0 then begin var selectedprj := TProjectType(Integer(ComboBox1.Items[ComboBox1.ItemIndex])); end;