Extracting Resource String
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
- 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;
- Choose Refactor > Extract Resource String menu command. The Extract Resource String dialog box opens.
- Enter a name for the resource string or accept the suggested name (the
Str
, followed by the string). - Click OK.
The created resource string is added into the
resourcestring
section. If there is noresourcestring
section, the refactoring engine creates theresourcestring
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.