In Delphi XE3, it seems that one can use either "System.SysUtils" or "SysUtils", "Vcl.FileCtrl" or "FileCtrl".
I read the article in http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/devcommon/usingnamespaces_xml.html , it seems the former is called full qualified namespace, while the latter is the generic name. But if i understand correct, one should add statements like:
"Uses System, Vcl", before one can use the units under these namespaces. But I check the codes but cannot find any "Uses System" or "Uses vcl". Why?
You are reading old documentation, and reading the wrong topic anyway.
System
and Vcl
in this context are actually Unit Scope Names, which are similar to, but quite different from, Namespaces. Unit Scope Names were introduced in XE2, to allow VCL and FMX to share common unit names under different scopes (Vcl.Forms
vs FMX.Forms
, etc). Existing VCL code being migrated to FMX did not (largely) need to be re-written, it could use
just Forms
, etc and magically pick up the correct scope based on project type. The same does not work with Namespaces.
The reason you don't have to explicitly specify Unit Scope Names in uses
statements in code is because they are configured at the project level instead, and by default most VCL projects have the System
and Vcl
scope names pre-configured.
So, when you use
just SysUtils
, FileCtrl
etc in your code, the compiler checks them against the project's Unit Scope Names and eventually finds System.SysUtils
, Vcl.FileCtrl
, etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With