1.变量赋初始值
1 const 2 {$J+} 3 num: Integer = 1; 4 {$J-} 5 begin 6 Inc(num); 7 ShowMessage(IntToStr(num)); {2} 8 end; 9 10 //或者写作: 11 const 12 {$WRITEABLECONST ON} 13 num: Integer = 1; 14 {$WRITEABLECONST OFF} 15 begin 16 Inc(num); 17 ShowMessage(IntToStr(num)); {2} 18 end;
2.利用initialization初始化
1 var 2 FilePath : string; 3 4 implementation 5 6 initialization 7 FilePath := ExtractFilePath(Application.ExeName) + ‘Test.xml‘; {..\Test.xml} 8 9 end.
时间: 2024-10-05 23:22:50