[SparForte][Banner]
[Top Main Menu] Intro | Tutorials | Reference | Packages | Examples | Contributors   [Back Page]      [Next Page]  

Basic Assignment and Expressions

Values can be assigned in an assignment statement or in a declaration.

The Assignment Statement (:=)

Values are assigned to variables with the assignment statement (:=). Unlike some languages, assignment is not an operator: it cannot be used in an expression.

Some types are "limited". This means they cannot be assigned using the assignment statement.

Primitive Operators

AdaScript expressions can contain the following operators:

  • uniary: +, -, not
  • exponentiation: **
  • arithmetic: +, -, *, /, & (string concatenation), rem (remainder), mod (modulo), and (bitwise and), or (bitwise or), xor (bitwise exclusive or), * (string duplication)
  • relational: =, /= (not equals), >=, >, <=, <, in, not in
  • boolean: and, or, xor (exclusive OR)

The bitwise operators are identical to the boolean operators: SparForte choses which to use on the context of the expression.

in and not in test for membership in a range. (In Ada, the range can be a type but under AdaScript types have no bounds.) The range can be an pair of numbers, characters (not strings) or a pair of enumerated items.

=> b := green in red..blue;
=> b := 5 not in 10..20;

in and not in are technically not operators.

Ada: and then and or else not yet implemented. Character ranges not yet implemented.

Expressions and Order of Operations

An expression is a combination of operands and operators used to compute a result value.

Expression operators are evaluated in the following order:

  • Factors: literals, variables are other values, uniary +, uniary -, subexpressions
  • Power Terms: **
  • Terms: /, mod, rem, *, &
  • Simple Expressions: +, -
  • Relations: =, /=, >=, >, <=, < in, not in
  • Boolean Expressions: and, or, xor

Subexpressions can be created using parantheses.

Assignment Statements

Assignment (:=) is a statement, not an operator, and cannot be used in expressions.

=> x := 5 * ( 7 + 2 );
=> s := "hello " & "there!";


 

[Right Submenu]

 AdaScript versus GCC

 Case Sensitivity

 Reserved Words

 Comments

 Literals

 Bourne Shell Word Expansions

 Fundamental Types

 User-defined Types

 Enumerated Types

 Arrays

 Records

 Basic Assignment

 The @ and % Operands

 Command Argument Shortcuts

 Redirection and Pipelines

 Command Line Interaction

 Built-in Shell Commands

 The Current Directory

 Database Commands

 Flow of Control

 Other Statements/ Subprograms

 External Commands

 Block Statements and Subprograms

 TCP/IP Sockets

 Numeric Formatting with Put

 Interpreter Directives

 Command Line Options

 Command Reference

 ASCII and Latin_1 Character Sets

 Common Error Messages

 Common PHP Functions and the SparForte Equivalent

[Back to Top] Back To Top [Small Forte Symbol]