252
edits
m (→streq()) |
|||
Line 2,346: | Line 2,346: | ||
== Extension functions new in FG 2020.1 == | == Extension functions new in FG 2020.1 == | ||
The following functions have been added to the nasal core library and will be released with FlightGear version 2020.1. | The following functions have been added to the nasal core library and will be released with FlightGear version 2020.1. | ||
Before the release they are available in the development branch "next". | |||
=== isfunc() === | === isfunc() === | ||
Line 2,358: | Line 2,358: | ||
=== isint() === | === isint() === | ||
Returns 1 if argument has a numeric value and x == floor(x), e.g. integer | {{Nasal doc | ||
|syntax = isint(x); | |||
|source = {{simgear file|simgear/nasal/lib.c|t=Source}} | |||
|text = Returns 1 if argument has a numeric value and x == floor(x), e.g. integer. | |||
}} | |||
=== isnum() === | === isnum() === | ||
Line 2,364: | Line 2,368: | ||
|syntax = isnum(x); | |syntax = isnum(x); | ||
|source = {{simgear file|simgear/nasal/lib.c|t=Source}} | |source = {{simgear file|simgear/nasal/lib.c|t=Source}} | ||
|text = Returns 1 if x has a numeric value otherwise 0. | |text = Returns 1 if typeof(x) is "scalar" and x has a numeric value otherwise 0. | ||
}} | |||
=== isscalar() === | |||
{{Nasal doc | |||
|syntax = isnum(x); | |||
|source = {{simgear file|simgear/nasal/lib.c|t=Source}} | |||
|text = Returns 1 if type or argument is a scalar (string or numeric), otherwise (vector, hash, func, ...) it returns 0. This is useful to check if a variable can be converted to string e.g. when useing the string concat operator "~". | |||
|example1 = var a = "foo"; | |||
var b=42; | |||
if (isscalar(a) and isscalar(b)) print(a~b); | |||
if (isstr(a)) print("a is a string"); | |||
if (isint(b)) print("b is an integer"); | |||
# if (isscalar(a))... is equivalent to if (typeof(a) == "scalar")... | |||
}} | }} | ||
=== isstr() === | === isstr() === | ||
Returns 1 if type or argument is a string, otherwise 0. | Returns 1 if type or argument is a string, otherwise 0. | ||
=== isvec() === | === isvec() === |
edits