1,376
edits
| Line 776: | Line 776: | ||
print(sprintf("% 6.1f", 1.4)); #prints " 1.4" | print(sprintf("% 6.1f", 1.4)); #prints " 1.4" | ||
print(sprintf("%06.1f", 1.4)); #prints "0001.4" | print(sprintf("%06.1f", 1.4)); #prints "0001.4" | ||
}} | |||
===str()=== | |||
{{Nasal doc | |||
|syntax = str(value); | |||
|source = {{simgear file|simgear/nasal/lib.c|l=186|t=Source}} | |||
|text = Convert given value (scalar) to string. If <code>value</code> is a number, it will be converted to a string. If <code>value</code> is a string, the same string will be returned. If <code>value</code> is not a scalar (hash, vector, nil), <code>nil</code> will be returned. | |||
|param1 = value | |||
|param1text = The value to convert to string. | |||
|example1 = | |||
var result = str(12); # result is a string "12" | |||
var result = str(12.5); # result is a string "12.5" | |||
var result = str("12.5"); # result is a string "12.5" | |||
var result = str([1, 2]); # result is a nil | |||
var result = str({ x: 0 }); # result is a nil | |||
var result = str(nil); # result is a nil | |||
}} | }} | ||
edits