Delphi Constant Rating: 3,1/5 8161 reviews
Delphi

Delphi Const

DelPhi is a scientific application which calculates electrostatic potentials in and around macromolecules and the corresponding electrostatic energies. It incorporates the effects of ionic strength mediated screening by evaluating the Poisson-Boltzmann equation at a finite number of points within a three-dimensional grid box.

I would use two arrays const CONST_NAMES: array[0.2] of string = ('const1', 'const2', 'const3'); CONST_VALUE: array[0.2] of Integer = (23, 523, 2553); procedure TForm1.Button1Click(Sender: TObject); var sl: TStringList; cnt: Integer; idx: Integer; value: Integer; begin sl:= TStringList.Create; try sl.LoadFromFile('filename. Txt'); for cnt:= 0 to sl.Count - 1 do begin idx:= AnsiIndexText(sl[cnt], CONST_NAMES); if idx  -1 then begin value:= CONST_VALUE[idx]; ShowMessage(IntToStr(value )); end else ShowMessage(Format('Unknow n constant%s', [sl[cnt]])); end; finally sl.Free; end; end; ziolko. Ahhh so const values are also read from file?? Then agree with MerijnB dynamically changing values of constants.

Delphi Constant Array Of String

Not possible (maybe someone can do some kind of reading process memory and changing it but I consider it not possible:) in this case only way is to create method: GetValue(const ConstName: string):Integer; which will lookup string list read from file but you'll have to re-write your code and change every occurance of 'const1' to GetValue('const1') for example: var a: Integer; a:= const1 * 5; will be: a:= GetValue('const1') * 5 ziolko. Other option, but you have to go to project options -> Compiler Assignable typed constants and CHECK this option: const const1: Integer = 0; const2: Integer = 0; const3: Integer = 0; procedure InitConsts; var sl: TStringList; cnt: Integer; idx: Integer; value: Integer; begin sl:= TStringList.Create; try sl.LoadFromFile('filename. Txt'); const1:= StrToInt(sl.Values['const1 ']); const2:= StrToInt(sl.Values['const2 ']); const3:= StrToInt(sl.Values['const3 ']); ShowMessage(IntToStr(const 1)); ShowMessage(IntToStr(const 2)); ShowMessage(IntToStr(const 3)); finally sl.Free; end; end; ziolko.