Gambas Documentation
Application Repository
Code Snippets
Compilation & Installation
Components
Controls pictures
Deprecated components
Developer Documentation
Development Environment Documentation
Documents
Error Messages
Gambas Playground
How To's
Language Index
Language Overviews
Arithmetical Functions
Arithmetic Operators
Array Declaration
Assignment Operators
Assignments
Binary Data Representation
Bits Manipulation Functions
Character Test Functions
Comparison methods
Complex numbers
Constant Declaration
Constant Expression
Conversion Functions
Datatype Functions
Datatypes
Date & Time Functions
Enumeration declaration
Error Management
Event Loop
Event Management
Events declaration
Expressions
External Function Management
File & Directory Functions
File & Directory Paths
File mode syntax
Floating Point Numbers
Formatting functions
Gambas Object Model
Global Special Event Handlers
Integer numbers
Intrinsic Functions
Language Constants
Localization and Translation Functions
Local Variable Declaration
Logarithms & Exponentials Functions
Logical Operators
Loop Control Structures
Method Declaration
Miscellaneous Control Structures
Miscellaneous Functions
Native Arrays
Native Container Classes
Object & Class Management
Operator Evaluation Order
Predefined Constants
Process Management
Property Declaration
Random Numbers Functions
Special Methods
Stream & Input/Output functions
String Functions
String Operators
Structure declaration
Test Control Structures & Functions
Trigonometric Functions
User-defined formats
Using reserved keywords as identifiers
Variable Declaration
Last Changes
Lexicon
README
Search the wiki
To Do
Topics
Tutorials
Wiki License
Wiki Manual

Expressions

An expression is a value (a constant, a predefined constant, a variable or the result of a function), which may optionally be preceded by certain operators depending on the type of value, followed by an operator and another value, and so on.

For numeric expressions:

{ number | constant | numeric function | numeric variable } [ operator [ sign ] { number | numeric function | numeric variable=} ... ]

number : a standard number

constant : a constant that represents a numeric value

numeric function : a user-defined or Intrinsic Functions that returns a numeric value

operator : any of the standard [/cat/arithop|arithmetic operators] ( + - * / ^ \ lang/div lang/mod plus AND OR or XOR)

numeric variable : any variable whose value is a number

For string expressions:

{ string | string constant | string function | string variable=} [ & { =string | string constant | string function | string variable=} ... ]

string : a set of zero or more characters surrounded by "

string constant : a predefined constant that represents a string value

string function : a user-defined or Intrinsic Functions that returns a string value

string variable : any variable whose value is a string

& : indicates that the string value to the right of the ampersand is to be concatenated to the end of the value to the right of the ampersand

For boolean expressions:

[ [/lang/not] ] { TRUE | FALSE | numeric constant | boolean constant | boolean function | boolean variable } [ boolean operator [ NOT ] { TRUE | FALSE | numeric constant | boolean constant | boolean function | boolean variable } ... ]

NOT : using NOT before a boolean value reverses the value

TRUE or FALSE : the standard boolean constants

numeric constant : a /wiki/cat/number|standard number which will be resolved to either TRUE or FALSE[1]

boolean constant : a /wiki/cat/constant|predefined constant that represents a boolean value

boolean function : a user defined or Intrinsic Functions that returns TRUE or FALSE or resolves to TRUE or FALSE[1]

boolean variable : any variable whose value is TRUE or FALSE or resolves either to TRUE or FALSE[1]

boolean operator: AND OR XOR = <> < > <= >=

Note that if the expression consists of a number with the operator AND, OR, or XOR followed by a number, it will be treated as an arithmetic expression rather than a boolean expression. At least one of the values in the expression must be a boolean value to produce a boolean expression.

[1]Note that a /wiki/cat/number, /wiki/cat/constant|predefined constant, /wiki/cat/arith|arithmetic function or numeric variable may be used as a boolean value. If the value of a number, numeric constant, numeric function, or variable is used in a boolean expression is zero, it resolves to FALSE ; all other numeric values used in a boolean expression resolve to TRUE.

See also