If Delphi developers makes a date time utility file its got to be orderly
that means all date time utilities must be in the file regardless of everything else so it can be found.
and this applies to every type of utility - floating point - currency
and this System.******** has to stop it needs total subject focus for once
or finding things is no longer RAD
Its not your fault its Delphi developers that needs to get a strict order process in place
and function FormatDateTime(const Format: string;
DateTime: TDateTime): string; overload; inline;
with procedure DateTimeToString(var Result: string; const Format: string;
DateTime: TDateTime); overload; inline;
the first one is the wrong words and needs to Go Go Go to remove all confusion as it does the same job but with the wrong words. the 2nd one needs to be a function and with the same name!!!
Then it aligns up with IntToStr and all the other utilities in an order to follow
what ever the order developed its got to be through out
If the name is correct - that is the most important thing!!!
if you change it from procedure to function big deal its able to be found and the IDE will point out the error and change that is an easy fix.
example Utilities.DateTime Utilities.Float Utilities.Currency Utilities.IntWords ⌠then the file its self becomes a bit of a help file in its self
Delphi 12 is big and has a lot to it that it needs a fundamental order to get around it is what Iâm saying.
I found âCopyMemoryâ - what a good Utility - Good sold naming too - better than moveâ
Another thing you do a search for a Delphi *.pas file and you sometimes get 3 different copies -
a) C:\Program Files (x86)\Embarcadero\Studio\23.0\lib\win32\release
b) C:\Program Files (x86)\Embarcadero\Studio\23.0\lib\win32\debug
c) C:\Program Files (x86)\Embarcadero\Studio\23.0\source\rtl\sys
d) C:\Program Files (x86)\Embarcadero\Studio\23.0\lib\win64\release
e) C:\Program Files (x86)\Embarcadero\Studio\23.0\lib\win64x\release
f) C:\Program Files (x86)\Embarcadero\Studio\23.0\lib\win64\debug
g) C:\Program Files (x86)\Embarcadero\Studio\23.0\lib\win64x\debug
Iâm running 64 bit Delphi so that rules the first 3 out, but which x64 one is being complied?
Any way Iâm heavy into a project and this forum is very supporting and I like the members hear - they are very helpful in deed and these little things can slow me down greatly where you guys makes the difference.
Iâm now heavy into the front end and what to be finished before Christmas.
thanks again
With the format string the âSystem.SysUtilsâ file shows them but the IDE will not compile them as they all do a red line under them in the IDE. Why?
The way you are typing out System.SysUtils.something is the full reference to the function and the namespace. If you hover over the red lines it should tell you what is wrong.
If you add the above âusesâ line to your program it should fix those problems unless youâve got something else wrong in your code like a syntax error or missing string terminator - the message on the red lines should give you a hint as to what is wrong.
I always copy and paste
System.SysUtils
to make secure its letter prefect
I put the full stop in and get the menu and add the .DateTimeToStr
to get System.SysUtils.DateTimeToStr
and that is where the error is as the complier will not accept it
yet it came out of the menu
Iâm not sure you understand the purpose of uses statements or how name spaces work.
If you add System.SysUtils to your uses clauses you donât need to respecify it again - just use DateTimeToStr on its own.
Writing it out in full like that is unnecessary and for many developers would be considered irritating - some software teams would explicitly ask you not to do that too since brevity and succinctness in code is considered an asset which is kind of why the concept of namespaces exists in most high-level programming languages.
The error you have is not anything to do with that. Perhaps if you take a screenshot of the error message or write down what it says someone here can suggest what is wrong and how to fix it.
Ian, I agree with you, but with with one caveat. There are some instances where you have to specify the unit name to inform the compiler which unit you want to use as the definition. This happens when the same item is defined in more than one unit.
Now, you might say that you put the unit that has the definition you want earlier or later in the USES list. This can get messed up if you sort your uses list alphabetically (I do). Now the wrong definition is used by the compiler and compiler-error chaos ensues.
Using the unitname.definitionname syntax insures that the correct one will be used. TBitmap defined in both WinApi.Windows and Vcl.Graphics: I am looking at you.
Yes, doing this unnecessarily drives me absolutely nuts too⌠as does âSelf.MethodNameâ, but that is a whole other rant.
My personal favorite is TRect which has driven me to distraction several times, particularly when 3rd party libraries suddenly decide itâs absolutely fine to create their own version.
uses system.sysutils; has to be installed in the correct place that when I type in the implementation area system.sysutils. the menu can only pop up if system.sysutils is linked to a file to reference from and so I select from the IDE menu the methods in the file but the methods do not settle to compile
is the system.sysutils.DCU file missing?
procedure TForm1.GridSetEditText();
Var
Val: string;
begin
Val := System.SysUtils.DateTimeToStr(MyDateTime,âdd,mmm,yyyyâ);
It goes on about an overload value not being set that is a complier error in Delphi code?
DateTimeToStr takes an optional format settings value which is not a string.
It is generally used to print out date/times in various standard windows formats depending on your Region, usually not for fully custom formats.
Note: You can put your cursor somewhere in the method name press F1 in Delphi, and mine at least finds some reasonable information on it for most of the Delphi supplied methods.
Also on my help page under see also for these methods, is a reference to Date and Time Support.