1

Please explain package use (in short sentences with small words (for Dummies)).

I just moved from D7 to XE2 and packages seem much more prevelant, and I seem to need to qualify a lot more things.

In D7 I would say uses windows and now I must say uses winapi.windows.

I find that when I call MessageDlg() I can't pass in mtError, I need to qualify it.

Before I go too far down the wrong road - what's the simple solution?

Can I somehow continue to use my old code with package names which I suspect are terminal (that is, for packages A.B.C I have auses C clause).

Can I add one statement somewhere to do this? Or configure the project.

Sorry to sound so dumb :-(

Mawg says reinstate Monica
  • 38,334
  • 103
  • 306
  • 551

2 Answers2

5

Package use is no different in XE2 than in earlier versions. What is different is that all of Embarcadero's unit names are now prefixed with new Unit Scope Names ("System", "Vcl", "Winapi", etc) to help designate which units belong to the RTL, the VCL, FireMonkey, specific platforms, etc.

You can update your code to fully qualify everything now, if you want to, but you do not have to. You can instead specify the particular scope names in the "Unit Scope Names" setting of the Project Options instead, then no code changes are needed (other than the usual changes when migrating from one version to another).

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
3

These are called unit scopes. Because of the new FireMonkey libraries, and the cross-platform support, it's required that you declare which unit you're referring to for types and function declarations.

You can set defaults using Project->Options->Compiler->Unit Scope Names. This is documented as well.

Ken White
  • 123,280
  • 14
  • 225
  • 444
  • 1
    Most code DOES NOT need to qualify scopes any more than in previous versions, if you make use of the "Unit Scope Names" list in the Project Options to centralize which scopes the project is using. – Remy Lebeau Jan 08 '12 at 06:51
  • 1
    @Remy: Umm... That's in the links I posted, and I specifically mentioned the project options. Did I miss something? – Ken White Jan 08 '12 at 06:58