dho*_*key 5 inno-setup pascalscript
我试图拆分一个 csv 字符串,然后遍历数组并更改这些字符串,然后再次将其构建回逗号分隔的字符串。
function StrSplit(Text: String; Separator: String): Array of String;
var
i, p: Integer;
Dest: Array of String;
begin
i := 0;
repeat
SetArrayLength(Dest, i+1);
p := Pos(Separator,Text);
if p > 0 then begin
Dest[i] := Copy(Text, 1, p-1);
Text := Copy(Text, p + Length(Separator), Length(Text));
i := i + 1;
end else begin
Dest[i] := Text;
Text := '';
end;
until Length(Text)=0;
Result := Dest
end;
function FormatHttpServer(Param: String): String;
var
build: string;
s: string;
ARRAY1: Array of String;
begin
ARRAY1 := StrSplit(param, ',');
build:='';
for s in ARRAY1 do
begin
build := build + DoSomething(C);
end;
end;
Run Code Online (Sandbox Code Playgroud)
我FormatHttpServer从别处打电话给。我无法编译脚本,因为在下一行我收到“类型不匹配错误”,我不明白为什么。它应该使用字符串 s 遍历字符串数组。
for s in ARRAY1 do
Run Code Online (Sandbox Code Playgroud)
Inno Setup Pascal Script 不支持for ... in语法。
您必须使用索引:
var
I: Integer;
A: array of string;
S: string;
begin
A := { ... };
for I := 0 to GetArrayLength(A) - 1 do
begin
S := A[I];
{ Do something with S }
end;
end;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1524 次 |
| 最近记录: |