我想对这段代码整段进行循环请问应该怎么写啊!
else if ((not g_Config) and (strscan(pchar(buffer),'#') <> nil))then
begin
g_Config := true;
SendCmd(PChar('config'));
end else if (not g_Config_if and g_Config)then
begin
g_Config_if := true;
str := 'int f0/'+trim(Edit1.Text);
SendCmd(PChar(str));
end
else if (not g_config_if_1 and g_config_if) then
begin
str5:='';
str5[0]:=chr(14);
j:=1;
k:=1;
for i:=1 to 17 do
begin
if (maskedit1.text[i]<>'-')then
begin
str5[j]:=maskedit1.text[i];
if ((k mod 4)=0)then
begin
j:=j+1;
str5[j]:='.';
end;
j:=j+1;
k:=k+1;
end;
end;
g_Config_if_1 := true;
str6 := 'switchport port-security mac-address '+ str5;
SendCmd(PChar(str6));
end
else if (g_config_if_1)then
begin
sendcmd(pchar('end'));
g_Login := true;
end;也就是说对这段代码从 else if开头到end;结尾开始执行循环20次
else if ((not g_Config) and (strscan(pchar(buffer),'#') <> nil))then
begin
g_Config := true;
SendCmd(PChar('config'));
end else if (not g_Config_if and g_Config)then
begin
g_Config_if := true;
str := 'int f0/'+trim(Edit1.Text);
SendCmd(PChar(str));
end
else if (not g_config_if_1 and g_config_if) then
begin
str5:='';
str5[0]:=chr(14);
j:=1;
k:=1;
for i:=1 to 17 do
begin
if (maskedit1.text[i]<>'-')then
begin
str5[j]:=maskedit1.text[i];
if ((k mod 4)=0)then
begin
j:=j+1;
str5[j]:='.';
end;
j:=j+1;
k:=k+1;
end;
end;
g_Config_if_1 := true;
str6 := 'switchport port-security mac-address '+ str5;
SendCmd(PChar(str6));
end
else if (g_config_if_1)then
begin
sendcmd(pchar('end'));
g_Login := true;
end;也就是说对这段代码从 else if开头到end;结尾开始执行循环20次
i:Integer
.
.
.
else
begin
for i:=1 to 20 do //设置个循环
begin
你的那段代码
end;
end;