Sidebar

Home



Expressions V4


Tutorials

How-To

Reference

  Lexical basics
  Type system
  Variables and assignment
  Operators
  Expression rules
  Control flow
  Functions
  Built-in functions
   None and NaN
   Arithmetic
   Algebra
   Logarithmic and Exponential
   Trigonometric
   Rounding and Centering
   Strings
   Output, Formatting, Clipboard, and Errors
   Dialog Functions
   Platform and Paths
  Methods and properties
  Built-in methods
   Common Value Methods
   Number Methods
   String Basic Methods
   String Slice Methods
   String Parsing Methods
   String Formatting Methods
   String Regex Methods
   String Trim and Case Methods
  Objects
  Built-in objects
   Global objects
    settings
    controller
    session
    python
   Collections
    array
    map
    bytes
   File Format I/O
    image_data
    image_stream
   Utils
    crypto
    timer
   Comm
    serial
   Dialogs
    file_open
    file_save
    msg_ok
    msg_ok_cancel
    msg_yes_no
    msg_password
   GUI objects
    window
    panel
    group
    splitpanel
    label
    textbutton
    drawablebutton
    togglebutton
    togglegroup
    textinput
    textedit
    numinput
    slider
    combobox
    listbox
    progressbar
    led
    separator
    menu
    image
    snake
  Classes and user-defined objects
  Include system
  Error model
  Execution model and sessions
  Host integration
  Limits and performance
  Formal reference
  Glossary

Cookbook

exprv4:reference:methods:common_value_methods



Common Value Methods

Common value methods can be called on any Expr value: `none()`, numbers, strings, and objects.

They are mostly used for validation before a script performs numeric work, string parsing, or optional-value handling.


is_none()

Checks whether the value is `none()`.

Item Description
Syntax `value.is_none()`
Arguments none
Returns boolean-style number

Example:

value = none();
 
if(value.is_none())
{
    print('missing value');
};

is_nan()

Checks whether the value is numeric NaN.

Item Description
Syntax `value.is_nan()`
Arguments none
Returns boolean-style number

Only a numeric NaN value returns true.

Example:

value = nan();
 
value.is_nan();       // true

is_num()

Checks whether the value is a number.

Item Description
Syntax `value.is_num()`
Arguments none
Returns boolean-style number

NaN is still a number, so `nan().is_num()` returns true.

Example:

(123).is_num();       // true
nan().is_num();       // true
'123'.is_num();       // false

is_num_notnan()

Checks whether the value is a usable number and not NaN.

Item Description
Syntax `value.is_num_notnan()`
Arguments none
Returns boolean-style number

Use this before calculations that require a valid numeric value.

Example:

if(feed.is_num_notnan() && feed > 0)
{
    print('valid feed');
};

is_num_int()

Checks whether the value is an integer numeric value.

Item Description
Syntax `value.is_num_int()`
Arguments none
Returns boolean-style number

Example:

(10).is_num_int();    // true
(10.5).is_num_int();  // false

is_string()

Checks whether the value is a string.

Item Description
Syntax `value.is_string()`
Arguments none
Returns boolean-style number

Example:

'abc'.is_string();    // true
123.is_string();      // use (123).is_string() in real code

When calling a method on a numeric literal, use parentheses:

(123).is_string();    // false

is_bool()

Checks whether the value can be interpreted as a boolean value.

Item Description
Syntax `value.is_bool()`
Arguments none
Returns boolean-style number

Finite numbers are boolean-compatible. Strings `true`, `false`, `1`, and `0` are also boolean-compatible.

Example:

(1).is_bool();        // true
'false'.is_bool();    // true
'abc'.is_bool();      // false

Previous: Built-in methods

Next: Number Methods

exprv4/reference/methods/common_value_methods.txt · Last modified: by 127.0.0.1

Page Tools