1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
2 |
"http://www.w3.org/TR/html4/strict.dtd"> |
3 |
<html> |
4 |
<head> |
5 |
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
6 |
<title>sprintf2</title> |
7 |
<meta http-equiv="Content-Style-Type" content="text/css"> |
8 |
<link rel="stylesheet" href="../../style.css" type="text/css"> |
9 |
</head> |
10 |
|
11 |
<body> |
12 |
|
13 |
|
14 |
<h1>sprintf2</h1> |
15 |
|
16 |
<p> |
17 |
Returns formatted output. |
18 |
</p> |
19 |
|
20 |
<pre class="macro-syntax"> |
21 |
sprintf2 strvar FORMAT [ARGUMENT ...] |
22 |
</pre> |
23 |
|
24 |
<h2>Remarks</h2> |
25 |
|
26 |
<p> |
27 |
FORMAT controls the output as in C language printf with ARGUMENTs converted to proper type first. |
28 |
The output string is stored in the string variable <strvar>. |
29 |
</p> |
30 |
|
31 |
<table> |
32 |
<caption>supported format style</caption> |
33 |
<tr> |
34 |
<th>type</th> |
35 |
<td>c, d, i, o, u, x, X, e, E, f, g, G, a, A and s</td> |
36 |
</tr> |
37 |
<tr> |
38 |
<th>flags(option)</th> |
39 |
<td>-, +, 0, # and blank(' ')</td> |
40 |
</tr> |
41 |
<tr> |
42 |
<th>width(option)</th> |
43 |
<td>decimal integer</td> |
44 |
</tr> |
45 |
<tr> |
46 |
<th>precision(option)</th> |
47 |
<td>nonnegative decimal integer(option), preceded by a period(.)</td> |
48 |
</tr> |
49 |
</table> |
50 |
|
51 |
<p> |
52 |
As a result of this command, the system variable "result" is set to one of the following values. |
53 |
</p> |
54 |
|
55 |
<table> |
56 |
<tr> |
57 |
<th>Value</th> |
58 |
<th>Status</th> |
59 |
</tr> |
60 |
<tr> |
61 |
<td>0</td> |
62 |
<td>Formatted successfully</td> |
63 |
</tr> |
64 |
<tr> |
65 |
<td>1</td> |
66 |
<td>No format string</td> |
67 |
</tr> |
68 |
<tr> |
69 |
<td>2</td> |
70 |
<td>Invalid format</td> |
71 |
</tr> |
72 |
<tr> |
73 |
<td>3</td> |
74 |
<td>Invalid argument</td> |
75 |
</tr> |
76 |
<tr> |
77 |
<td>4</td> |
78 |
<td>Invalid destnation variable</td> |
79 |
</tr> |
80 |
</table> |
81 |
|
82 |
<h2>Example</h2> |
83 |
|
84 |
<pre class="macro-example"> |
85 |
sprintf2 ver 'Tera Term 4.%d' 51 |
86 |
messagebox ver 'sprintf test(1)' |
87 |
|
88 |
sprintf2 win 'Windows %d (+%s)' 2000 'SP4' |
89 |
messagebox win 'sprintf test(2)' |
90 |
|
91 |
sprintf2 test '%s=%d %s=0x%x' 'dec' 10 'hex' 33 |
92 |
messagebox test 'sprintf test macro(3)' |
93 |
</pre> |
94 |
|
95 |
<h2>See also</h2> |
96 |
|
97 |
<ul> |
98 |
<li>"<a href="sprintf.html">sprintf</a>"</li> |
99 |
</ul> |
100 |
|
101 |
</BODY> |
102 |
</HTML> |