Function
makebool
Purpose
Makes a bool value from other types of values.
Return Type
bool
Syntax
makebool(<type>(<value>))
Arguments
<type> Can be real, int, str, bool.
<value> A value of type <type>. This can be a constant,
variable, function call to another function, expression, inline
command or a combination of these, together
resulting in a value of type <type>.
Return Value
A constant of type bool. The <value>, whether it is a variable,
expression, or anything else, remains unchanged.
Stream Input
Streams apply to commands and not to functions.
Stream Output
Streams apply to commands and not to functions.
Stream Error
Streams apply to commands and not to functions, although any errors
will be written here.
Description
Depending on <type>, makebool() function performs
the type conversion as follows.
<type> Return Value
------- -------------------------------------------------------------
real false if the real value is 0.0, else true.
int false if the int value is 0, else true.
str If the str value is "true", true is returned.
Else, false is returned.
bool The original bool value is returned. (A copy
of the original bool value is made.)
Restrictions
Although any type can be converted to any other type using the makeXXXX() functions,
be careful, as it may sometimes produce unintended results.
All system functions are declared as global, and can not be redeclared (overloaded).
Valid Examples
var bool agreement
var str s
.
.
.
# s is assigned one of the words - yes, no, true, false, on, off.
sal "^yes^" "true" $s >null # We only want to alter $s, not see the output.
sal "^on^" "true" $s >null
set $agreement=makebool(str($s))
if ($agreement)
echo "There is Agreement."
else
echo "There is No Agreement."
endif
Will indicate whether the response ($s) is positive or negative.
Invalid Examples
var str s
...
# s is assigned a string value.
# We will assume that s does indeed
# contain either "true" or "false"
var bool b1
var bool b2
set $b1 = $s # Automatic conversion.
set $b2 = makebool(str($s)) # Correct coversion.
$b1 assignment is incorrect, as it will be true irrespective
of whether $s contains "true" or "false".
$b2 assignment is correct, as it extracts the original
bool value from the string.
See Also
constant
var
makereal
makeint
makestr
type
conversion
system
var
|
© 2008-2013, biterScripting.com. All rights reserved.
biterScripting, biterScript, biterBrowser, biterMobile, biterScripting.com, FVA (Forward Variable Assignment) are trademarks of biterScripting.com. Is it biterScripting-compatible ? is a service mark of biterScripting.com.
Explorer, Unix, Windows are trademarks, service marks or other forms of intellectual property of their respective owners.
|