odbo 发表于 2012-5-31 21:49:03

鱼c数组01_15讲 实例问题

本帖最后由 乐yi忘忧 于 2012-6-1 11:38 编辑

var
ran_num: array of Integer;
I, 最大值, 下标: Integer;

begin
edt1.Text := '';
edt2.Text := '';
edt3.Text := '';
最大值 := 1;

for I := 1 to 10 do
begin
   ran_num :=10+ Random(90);

   if (最大值 < ran_num) then
   begin
       最大值 := ran_num;
       下标 := I;
   end;

   edt1.Text := edt1.Text + ',' + IntToStr(ran_num);
   edt2.Text := IntToStr(最大值);
   edt3.Text := IntToStr(下标);
end;

edt1.Text := copy(edt1.Text, 2, 30);
//edt1.Text := Delete(edt1.Text, 1, 1);
//删除最前面","号,为何delete无法通过????


以上是开始键的代码不知道问题出在哪里?讲最后的copy语句换成delete语句就无法编译通过
Unit1.pas(58): E2197 Constant object cannot be passed as var parameter

为何copy能通过而delete无法通过
procedure Delete(var S: String; Index: Integer; Count: Integer);
function Copy(S: <string or dynamic array>; Index: Integer; Count: Integer): string;
这是两个的英文说明 英文太差 看不懂 有老师帮忙说明下差别吗

乐yi忘忧 发表于 2012-5-31 23:12:35

Constant object cannot be passed as var parameter 常量对象不能作为变量参数传递
procedure Delete(var S: String; Index: Integer; Count: Integer);
function Copy(S: <string or dynamic array>; Index: Integer; Count: Integer): string;

delete是过程,copy是函数

odbo 发表于 2012-5-31 23:54:47

谢谢 这下明白加个中间量应该就能解决

1588/足球 发表于 2012-6-7 11:19:59

我也是来学习的呵呵

五棵木 发表于 2013-4-24 22:38:35

真是难得给力的帖子啊。
页: [1]
查看完整版本: 鱼c数组01_15讲 实例问题