Array 問題 |
答題得分者是:jow
|
apple12
一般會員 發表:28 回覆:23 積分:10 註冊:2003-05-10 發送簡訊給我 |
在程式開始會執行不列
type logtype = record class : String[6]; type : String[100]; end; logrecord : array of logtype; begin logrecord[i].class := 'a'; logrecord[i].type := 'b'; end 關閉程式時,會有以下錯誤 Exception EAccessViolation in modele XXX.exe at 000A110B. Access violation at address 004a111B in module XXX.exe. Read of address1448EDAC. |
jow
尊榮會員 發表:66 回覆:751 積分:1253 註冊:2002-03-13 發送簡訊給我 |
(1)
type, class是Delphi保留字 (2) logrecord : array of logtype; 其中logrecord 必須配置記憶體 SetLength(logrecord, a_length); (3) i 的範圍 0~Length(logrecord)-1 (4) 釋放記憶體 logrecord := nil; ===================引 用 apple12 文 章=================== 在程式開始會執行不列 type logtype = record class : String[6]; type : String[100]; end; logrecord : array of logtype; begin logrecord[i].class := 'a'; logrecord[i].type := 'b'; end 關閉程式時,會有以下錯誤 Exception EAccessViolation in modele XXX.exe at 000A110B. Access violation at address 004a111B in module XXX.exe. Read of address1448EDAC.
編輯記錄
jow 重新編輯於 2007-11-15 18:10:43, 註解 無‧
|
apple12
一般會員 發表:28 回覆:23 積分:10 註冊:2003-05-10 發送簡訊給我 |
|
jow
尊榮會員 發表:66 回覆:751 積分:1253 註冊:2002-03-13 發送簡訊給我 |
|
kevin2004
資深會員 發表:18 回覆:463 積分:416 註冊:2005-05-29 發送簡訊給我 |
你寫的就好幾個錯,不用等退出,Compile就通不過
type logtype = record class : String[6]; type : String[100]; end; ===>class與type是保留字,不可作欄位名稱 logrecord : array of logtype; begin logrecord[i].class := 'a'; logrecord[i].type := 'b'; end ==>i未在Var中定義 ==>i 是未定義值,不可
------
Kevin |
apple12
一般會員 發表:28 回覆:23 積分:10 註冊:2003-05-10 發送簡訊給我 |
type logtype = record subclass : String[6]; tablename : String[20]; end; public logrecord : array of logtype; 程式開始時會啟動以下: procedure TfrmMain.Init; var w_query : TSQLQuery; i : Integer; begin w_query := TSQLQuery.Create(Nil); w_query.SQLConnection := DM.SQLConnection1; w_query.Close; w_query.sql.Clear; w_query.Sql.add('select * from abc '); w_query.Open; i := 0; SetLength(logrecord, w_query.recordcount-1); while not w_query.Eof do begin logrecord[i].subclass := w_query.fieldbyname('raditem').asstring; logrecord[i].tablename := w_query.fieldbyname('value').asstring; inc(i); w_query.Next; end; w_query.Free; end; 當結束程式時,便會有錯誤。 如果不執行上述,便不會有錯。 |
jow
尊榮會員 發表:66 回覆:751 積分:1253 註冊:2002-03-13 發送簡訊給我 |
|
apple12
一般會員 發表:28 回覆:23 積分:10 註冊:2003-05-10 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |