BlitzMax

BlitzMax

  • Downloads
  • Docs
  • API
  • Resources
  • About

›Language

Setup

  • Getting Started
  • Win32
  • Linux
  • macOS
  • Android
  • iOS
  • Raspberry Pi
  • NX (Switch Homebrew)
  • Custom Settings

Tutorials

  • Beginners Guide
  • OOP Tutorial
  • Network Programming
  • TCP Socket Programming

Language

  • Arrays
  • Basic Compatibility
  • Collections
  • Comments
  • Conditional Compiling
  • Constants
  • Data Types
  • Debugging
  • Enums
  • Exceptions
  • Expressions
  • Functions
  • Identifiers
  • Literals
  • Modules
  • Objects
  • Program Flow
  • Slices
  • Strings
  • User Defined Types
  • Variables
  • Advanced Topics

    • Interfacing With C
    • Memory Management
    • Pointers
    • Custom Pre/Post Compilation Scripts
    • Creating DLLs

Tools

  • MaxIDE
  • BlitzMax Make (bmk)
  • BlitzMax Compiler (bcc)
Edit

Expressions

Operators

BlitzMax supports the following operators. Operators are grouped into levels of precedence, starting with the highest precedence operators:

OperatorSyntax
Sub expression( Expression )
New objectNew Typename
LiteralValue
IdentifierValue
Self objectSelf
Super objectSuper
Null valueNull
PiPi
TrueTrue
FalseFalse
MemberExpression . Identifier
IndexExpression [ IndexExpressions ]
CallExpression ( Parameters )
Posate+ Expression
Negate- Expression
Bitwise complement~ Expression
Boolean notNot Expression
Value byte sizeSizeOf Expression
Variable addressVarptr Variable
Convert type expressionType Expression
PowerExpression ^ Expression
MultiplyExpression * Expression
DivideExpression / Expression
RemainderExpression Mod Expression
Bitwise shift leftExpression Shl Expression
Bitwise shift rightExpression Shr Expression
Arithmetic shift rightExpression Sar Expression
AddExpression + Expression
SubtractExpression - Expression
Bitwise andExpression & Expression
Bitwise orExpression | Expression
Bitwise exclusive orExpression ~ Expression
EqualExpression = Expression
Not equalExpression <> Expression
Less thanExpression < Expression
Greater thanExpression > Expression
Less than or equalExpression <= Expression
Greater than or equalExpression >= Expression
Conditional andExpression And Expression
Conditional orExpression Or Expression

In addition, the following built in functions are also supported:

FunctionSyntax
Character codeAsc ( Expression )
CharacterChr ( Expression )
Value lengthLen ( Expression )

Null returns 0, an empty string, an empty array, the null object or a pointer to 0 depending on context.

True and False are integer constants with the values 1 and 0, respectively.

The index operator can be used on either arrays or strings. If used on an array, the element at the specified index is returned. If used on a string, the character code of the character at the specified index is returned.

The Not operator inverts the logic of a boolean expression. If the expression evaluates to true, Not returns false and vice versa.

Asc returns the character value of the first character of a string, or -1 if the length of the string is 0.

Chr constructs a 1 character string with the specified character value.

Len can be used with either a string or array. When used with a string, Len returns the number of characters in the string. When used with an array, Len returns the number of elements in the array. In the case of multidimensional arrays, Len returns the total number of elements.

Boolean expressions

It is frequently necessary to consider an expression as true or false, for example, for use with an If statement.

The rules for determining whether an expression is true or false are:

Expression TypeTruth condition
NumericTrue if value is not equal to 0
ObjectTrue if object is not equal to Null
StringTrue if length is not equal to 0
ArrayTrue if length is not equal to 0
← ExceptionsFunctions →
  • Operators
  • Boolean expressions
BlitzMax
Docs
Getting StartedDownloadsAbout
Community
ResourcesSyntaxBomb Forums
More
GitHubStarChat on Discord
Copyright © 2023 Bruce A Henderson