You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Apophysis 7x脚本Format函数调用非法参数报错求助

Apophysis 7x脚本Format函数参数非法运行时错误修复

问题场景

在Apophysis 7x 15D 32bit中编写批量渲染脚本时,执行Format('_%.3d', [i])语句触发运行时错误,提示"Format函数参数非法",将格式符改为%u后问题依然存在。

报错信息

RUNTIME ERROR
Illegal argument to Format function when evaluating instruction CallProc ($1,$2,$6DDB54,$66E0E98, "Format").
Stack content is: []. Source position: 25,63.

关联脚本代码

{ Filename : 110421.aposcript }
with Flame do
begin
    SampleDensity := 100;
    Oversample := 1;
    FilterRadius := 0.7;
end;

with Renderer do
begin
    Width := 640;
    Height := 320;
end;

Pcts := 36; //输出する枚数
fPath := 'C:\Apophysis\110421\'; //出力する画像ファイルを入れるフォルダ。事前に作っておく
fName := '110421'; //ファイル名のヘッダ文字列
fType := 'bmp'; //拡張子

for i := 0 to Pcts - 1 do
begin
    SetActiveTransform(0);
    Rotate(360 / Pcts);

    Renderer.Filename := fPath + fName + Format('_%.3d', [i]) + '.' + fType;
    SetRenderBounds;
    Render
end;

UpdateFlame := False;

修复方案

将Format函数的格式字符串从'_%.3d'修改为'_%03d',修改后的代码行如下:

Renderer.Filename := fPath + fName + Format('_%03d', [i]) + '.' + fType;

原因说明

Apophysis脚本引擎基于Pascal语法,其Format函数的规则与Delphi一致:

  • %.3d是浮点数格式符,用于保留三位小数,传入整数类型的i会导致参数类型不匹配,触发非法参数错误。
  • %03d是整数格式符,表示将整数格式化为3位长度,不足时自动补前导零,完全匹配循环变量i的整数类型。

内容的提问来源于stack exchange,提问作者fukuku

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 11:52:38