Previous: Patsubst, Up: Text handling [Contents][Index]
½ñ¼°ÉÕ¤½ÐÎϤÏformat
¤ò»È¤Ã¤Æ¹Ô¤¦¤³¤È¤¬¤Ç¤¤Þ¤¹¡£
format(format-string, ...)
¤³¤Î¥Þ¥¯¥í¤ÏC¸À¸ì¤Î´Ø¿ôprintf
¤È¤è¤¯»÷¤¿Æ°ºî¤ò¤·¤Þ¤¹¡£
ºÇ½é¤Î°ú¿ô¤Ï½ñ¼°»ØÄêʸ»úÎó¤Ç‘%’»ØÄê¤ò´Þ¤á¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£
format
¤ÏŸ³«¤µ¤ì¤ë¤È½ñ¼°ÉÕ¤Îʸ»úÎó¤Ë¤Ê¤ê¤Þ¤¹¡£
2, 3¤ÎÎã¤ò»È¤Ã¤ÆÀâÌÀ¤¹¤ë¤Î¤¬°ìÈ֤Ǥ·¤ç¤¦¡£
define(`foo', `The brown fox jumped over the lazy dog') ⇒ format(`The string "%s" is %d characters long', foo, len(foo)) ⇒The string "The brown fox jumped over the lazy dog" is 38 characters long
See Loops¤ÇÄêµÁ¤µ¤ì¤Æ¤¤¤ëforloop
¥Þ¥¯¥í¤ò»È¤Ã¤Æ
ɽ·Á¼°¤Î½ÐÎϤò¤¹¤ë¤È¤¤Ïformat
¤ò¼¡¤Î¤è¤¦¤Ë»È¤¦¤³¤È¤¬¤Ç¤¤Þ¤¹¡£
forloop(`i', 1, 10, `format(`%6d squared is %10d ', i, eval(i**2))') ⇒ 1 squared is 1 ⇒ 2 squared is 4 ⇒ 3 squared is 9 ⇒ 4 squared is 16 ⇒ 5 squared is 25 ⇒ 6 squared is 36 ⇒ 7 squared is 49 ⇒ 8 squared is 64 ⇒ 9 squared is 81 ⇒ 10 squared is 100
ÁȤ߹þ¤ß¥Þ¥¯¥íformat
¤ÏANSI C¤Î‘printf’´Ø¿ô¤ò¥â¥Ç¥ë¤È¤·¤Æ¤ª¤ê¡¢
¼¡¤Îɸ½àŪ¤Ê‘%’»ØÄê¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Þ¤¹: ‘c’, ‘s’, ‘d’,
‘o’, ‘x’, ‘X’, ‘u’, ‘e’, ‘E’, ‘f’¡£
¤Þ¤¿¥Õ¥£¡¼¥ë¥ÉÉý¤ÈÀºÅÙ»ØÄê¡¢¥â¥Ç¥£¥Õ¥¡¥¤¥¢ ‘+’, ‘-’, ‘ ’,
‘0’, ‘#’, ‘h’, ‘l’¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Þ¤¹¡£
printf
¤Îưºî¤Ë¤Ä¤¤¤Æ¹¹¤Ë¾Ü¤·¤¤¤³¤È¤Ï
C ¥é¥¤¥Ö¥é¥ê¥Þ¥Ë¥å¥¢¥ë¤ò¸«¤Æ¤¯¤À¤µ¤¤¡£