Extracting Resource String

From RAD Studio
Jump to: navigation, search

Go Up to Refactoring Procedures Index


Editing Delphi code in the Code Editor, you can use the Refactor > Extract Resource String menu command to convert the selected quoted string to the resource string.

To convert a string constant to a resource string

  1. In the Code Editor, click the quoted string to be converted to a resource string, for example, in the following code, click inside the 'Hello World' string:
procedure foo;
begin
	Writeln('Hello World');
end;
  1. Choose Refactor > Extract Resource String menu command. The Extract Resource String dialog box opens.
  2. Enter a name for the resource string or accept the suggested name (the Str, followed by the string).
  3. Click OK.

The created resource string is added into the resourcestring section. If there is no resourcestring section, the refactoring engine creates the resourcestring section in the implementation section of your code. The original string is replaced with the new resource string name:

resourcestring
	strHelloWorld = 'Hello World';

procedure foo;
begin
	Writeln(StrHelloWorld);
end.

See Also