Is (function): Difference between revisions
Jump to navigation
Jump to search
(Created page with "ISARRAY(''expression'') ISDATE(''expression'') ISEMPTY(''expression'') ISNULL(''expression'') ISNUMERIC(''expression'') ISOBJECT(''expression'') '''Description''' The I...") |
|||
(9 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
''This function is for BASIC compatibility. It is not available in pure JavaScript projects.'' | |||
IsArray(''expression'') | |||
IsDate(''expression'') | |||
IsEmpty(''expression'') | |||
IsNull(''expression'') | |||
IsNumeric(''expression'') | |||
'''Description | IsObject(''expression'') | ||
== Description == | |||
The Is functions return TRUE if a variable type corresponds to the function call, FALSE is returned otherwise. The required parameter, expression, is the variable whose type status is being determined. | The Is functions return TRUE if a variable type corresponds to the function call, FALSE is returned otherwise. The required parameter, expression, is the variable whose type status is being determined. | ||
IsDate() checks to see if the string is in a valid date format - it does not check to see if the date actually exists. IsDate("02/30/15") will return True. Additional checking will need to be done in your code to handle different date formats. | |||
== Example (Basic) == | |||
<pre> | <pre> | ||
Rem Is Functions Example | |||
Dim Children(3), Chef, When | |||
TestVariable Children | TestVariable Children | ||
Chef = 1 | Chef = 1 | ||
TestVariable Chef | TestVariable Chef | ||
When = | When = Now | ||
TestVariable When | TestVariable When | ||
Sub TestVariable(x) | |||
If IsArray(x) Then | |||
Print "The variable is an array." | |||
ElseIf IsDate(x) Then | |||
Print "The variable is a date." | |||
ElseIf IsNumeric(x) Then | |||
Print "The variable is a number." | |||
End If | |||
End Sub | |||
</pre> | </pre> | ||
== Output == | |||
<pre> | <pre> | ||
Line 44: | Line 48: | ||
</pre> | </pre> | ||
== Related Items == | |||
[[typename|TypeName]], [[vartype|VarType]] | |||
[[Category:Language Reference]] | |||
[[Category:Variable Handling]] | |||
[[ | [[Category:BASIC Functions]] |
Latest revision as of 15:27, 25 March 2019
This function is for BASIC compatibility. It is not available in pure JavaScript projects.
IsArray(expression)
IsDate(expression)
IsEmpty(expression)
IsNull(expression)
IsNumeric(expression)
IsObject(expression)
Description
The Is functions return TRUE if a variable type corresponds to the function call, FALSE is returned otherwise. The required parameter, expression, is the variable whose type status is being determined.
IsDate() checks to see if the string is in a valid date format - it does not check to see if the date actually exists. IsDate("02/30/15") will return True. Additional checking will need to be done in your code to handle different date formats.
Example (Basic)
Rem Is Functions Example Dim Children(3), Chef, When TestVariable Children Chef = 1 TestVariable Chef When = Now TestVariable When Sub TestVariable(x) If IsArray(x) Then Print "The variable is an array." ElseIf IsDate(x) Then Print "The variable is a date." ElseIf IsNumeric(x) Then Print "The variable is a number." End If End Sub
Output
The variable is an array. The variable is a number. The variable is a date.