Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
236 views
in Technique[技术] by (71.8m points)

Can you initialize variables in the var declation section using a function in Delphi?

I'm kind of rusty on Delphi. Used in the early nineties but am C# programmer now. I'm current working on a Delphi project.

I have to transform a lot of .pas file for localization of strings. I've written a C# program to do the transformation. The idea is to parse all .pas files an everywhere there a Dutch text string replace it with call to our language routines. I now find the problem that there a lot of constants in many of the units that have to transform to variables. The current implementation does it like this but this doesn't compile:

before: unit _TypesConstantsCommon;

interface

uses System.SysUtils;

const
  

    cDEELPRJN_OMSCHRIJVING_OPSTELLEN_OFFERTE = 'Opstellen offerte';

after:

unit _TypesConstantsCommon;

interface

uses System.SysUtils;

var

      cDEELPRJN_OMSCHRIJVING_OPSTELLEN_OFFERTE:string = TLanguagesManager.GetSingleton.GetText(c_TypesConstantsCommon1);

Is this at all possible? If not what should I generate to get this done?

question from:https://stackoverflow.com/questions/65851262/can-you-initialize-variables-in-the-var-declation-section-using-a-function-in-de

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...