我有以下設置:會員沒有改變對轉讓
//code from unit
...
TObjectList<T:TObject>=class(TObject)
private
function GetItem(Name: string): T;
function GetItemByIndex(Index: Integer): T;
public
property Items[Name:string]:T read GetItem;default;
property Item[Index:Integer]:T read GetItemByIndex;
end;
...
{ TObjectList<T> }
function TObjectList<T>.GetItem(Name: string): T;
begin
Result:=T(FindComponent(Name));
end;
function TObjectList<T>.GetItemByIndex(Index: Integer): T;
begin
Result:=T(Components[Index]);
end;
...
TStringEval=record
private
FValue:string;
public
function AsString:string;
function AsInteger:Integer;
function AsFloat:Double;
function AsBoolean:Boolean;
function AsDateTime:TDateTime;
function AsHex:string;
procedure SetValue(const S:string);overload;
procedure SetValue(const I:Integer;const AsHex:boolean=false);overload;
procedure SetValue(const F:Double);overload;
procedure SetValue(const B:Boolean);overload;
procedure SetValue(const D:TDateTime);overload;
...
TConsoleVariable=class(TConsoleCommand)
...
property Value:TStringEval read GetValue write SetValue;
...
TConsole=class(TObjectList<TConsoleCommand>)
...
property Variables[Name:string]:TConsoleVariable read GetVariable;
...
function TConsole.GetVariable(Name: string): TConsoleVariable;
begin
Result:=TConsoleVariable(Items[Name]);
end;
...
//main application code, the troublesome line.
Console.Variables['developer'].Value.SetValue(MESSAGELEVEL_VERBOSE);
...
這行永遠不會改變的變量的原因,我無法理解的價值。我的代碼的其他部分也有類似的問題。控制檯變量最初由控制檯本身賦值爲1。我暫時想要將它設置的更高,以便在不重新編譯控制檯代碼的情況下從應用程序獲取更詳細的輸出(它位於程序包中)。
難以檢查不能編譯的不完整代碼;可能你的代碼會將一個值賦給一個隱藏的臨時變量,而不是你需要的變量。 – kludg
爲了記錄,代碼被放置在幾個單元中,分佈在應用程序和包中,您如何期望我展示它以便編譯它? – ZzZombo
使SSCCE重現問題;當然不是一件難事。 – kludg