Anything which represents a value can be used in an expression. For example, commands can be used in expressions (as you have already experienced with the operators and the Str command) if they return a value. It is then that value which is used in the expression.
You can make your expressions as complex as you like (or fully expand them for readability and clarity). PureBasic will automatically simplify the expression to increase the speed at which is calculated when your program runs.
The following example shows a variety of expressions. You can find the source here.
OpenConsole()
; A simple expression
simple.l = 8
expression.f = simple * 3 + 2
; More complex example
detail$ = "This is the value of "
var_name.s = " expression"
output_string.s = detail$ + var_name + ": " + StrF(expression)
PrintN(output_string)
PrintN("Press return to exit")
Input()
CloseConsole()
End
| Previous topic | Chapter contents | Next topic |
|---|---|---|
| Operator Precedence | User Guide contents | Summary |