Einzelnen Beitrag anzeigen

C.Schoch

Registriert seit: 2. Jan 2006
Ort: Wüstenrot
235 Beiträge
 
Turbo Delphi für Win32
 
#1

Property gibt manchmal falsche Werte zurück

  Alt 29. Jan 2011, 16:40
Hi,

Ich habe eine property welches einen record zurück gibt:

Delphi-Quellcode:

  TStep = record
    Name : array[0..NUM_OF_LANGS - 1] of string;
    OutputMode : array[0..NUM_OF_OUTPUTS - 1] of Integer;
    Input : array[0..NUM_OF_INPUTS - 1] of TInput;
    Intervall : array[0..NUM_OF_INTERVALLS - 1] of TIntervall;
    AnalogIn : array[0..NUM_OF_ANALOG_IN - 1] of TAnalogIn;
    AnalogOut : array[0..NUM_OF_ANALOG_OUT - 1] of Real;
    AlarmStep : Integer;
    AlarmCond : Integer;
    NextCond : Integer;
    ContrTime : Integer;
    Loops : Integer;
    NextStep : Integer;
    Message : Integer;
    Time : Integer;
  end;

    function GetStep(Index : Integer) : TStep;
    procedure SetStep(Index : Integer; const Value : TStep);

    property Step[index : Integer] : TStep read GetStep write SetStep;


function TCleanProgParser.GetStep(Index : Integer) : TStep;
begin
  if not InRange(index, 0, NUM_OF_STEPS - 1) then
  begin
    raise Exception.CreateFmt('Selected Step Out of Range Min: %d, Max: %d, Is: %d',
      [0, NUM_OF_STEPS - 1, index]);
  end;
  if InRange(FSelectedProgram, 1, FFormatCount) then
  begin
    Result := FProgram[FSelectedProgram - 1].Step[index];
  end;
end;
Aufgerufen wird das ganze so:

Delphi-Quellcode:
procedure TForm5.ChangeStep;
var
  i : Integer;
  Data : TInputData;
  NodeData : PInputData;
  Node : PVirtualNode;
  Step : TStep;
begin
    Step := Parser.Step[seStepInput.AsInteger];
    eStepNameInput.Text := Step.Name[seLanguage.asInteger - 1];
    eStepNameOutput.Text := Step.Name[seLanguage.asInteger - 1];
 
...
end;
Nun kommt es manchmal vor, dass in "Step" andere Werte stehen als in "FProgram[FSelectedProgram - 1].Step[index]".

Das ist aber nicht immer so, aber wenn es einmal aufgetreten ist kommt es immer nahezu jedes mal vor

Hat einer von euch eine Idee woher das kommen könnte
Tschau Christian
Das System hofft auf Besserung
[Siemens]

Geändert von C.Schoch (29. Jan 2011 um 18:09 Uhr)
  Mit Zitat antworten Zitat