简体   繁体   English

imageJ 宏中的字符串格式

[英]String format in imageJ macro

I would like to convert an integer into a string with leading zeros in ImageJ / Fiji macro editor using String.format() function.我想使用String.format() function 在 ImageJ / Fiji 宏编辑器中将 integer 转换为带有前导零的字符串。 With this code:使用此代码:

s = String.format("%04d", 13);
print(s);

I get the following error:我收到以下错误:

Unrecognized String function in line 2
s = String . <format> ("%04d" , 13);

Any ideas?有任何想法吗?

After the documentation https://imagej.nih.gov/ij/developer/macro/functions.html#S this should work:在文档https://imagej.nih.gov/ij/developer/macro/functions.html#S之后,这应该可以工作:

String.format(format, number) - Returns a formatted string using the specified format and number. String.format(format, number) - 返回使用指定格式和数字的格式化字符串。

Version: ImageJ 1.53c with Java 1.8.0_172 (64-bit)版本:ImageJ 1.53c 与 Java 1.8.0_172(64 位)

The String.format macro function requires ImageJ 1.53d or newer . String.format宏 function 需要 ImageJ 1.53d 或更高版本 The version of ImageJ 1.x shipped with Fiji is a few versions behind due to breaking changes in ImageJ 1.x that the ImageJ2 team still need to work around.由于 ImageJ2 团队仍需要解决的 ImageJ 1.x 中的重大更改,斐济随附的 ImageJ 1.x 版本落后了几个版本。 In the meantime, you can use the Help > Update ImageJ... command to update the version of ImageJ 1.x bundled with Fiji.同时,您可以使用Help > Update ImageJ...命令更新与 Fiji 捆绑的 ImageJ 1.x 版本。 Be aware that this command will hard quit your running ImageJ instance after downloading the chosen version.请注意,下载所选版本后,此命令将硬退出正在运行的 ImageJ 实例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM