Right-Hand Side Expressions

Prev Next

Overview

The RHS Expressions are expressions on the Right-Hand Side of the assignment symbol or assignment operator which are used to specify, retrieve and/or calculate values. Following rules apply:

RHS Expressions are applicable in following cases:

  • On the right-hand-side of all Assignments,
  • Input Parameters in procedure and function calls
  • Variable names, example: ('Category '+name[])[]
    • Parentheses are mandatory if the variable specified as a LHS expression, e.g. (name[])[] = Hello;
    • Otherwise, parentheses are mandatory if any calculations are applied in order to encompass the whole result, e.g. ('My '+name[])[] = Nick; where it is ensured that 'My ' is part of the variable name to use.

The following are not allowed in RHS expressions:

  • Applying ad-hoc operations on calculated expressions and function calls, e.g. (a[]+4)++.
  • Applying them on the left-hand-side of assignment symbols, as I/O parameters in function and procedure calls, and transactions


Note: Whenever the term Expression is referred without indications on left/right-hand sides, then the right-hand-side is assumed.

Examples

  echo(RHS Examples with variables);

  a[]        = 10;
  a[name]    = 'My Name';
  a[four]    = (a[] - 2)/2;
  a[colors]  = { red, yellow, green, blue };
  a[nine]    = sqrt(81);
  see(a[]);

  echo(RHS Examples with a table);
  table initialize ( List, {{Name, Score}, { Amy, 10}, { Bea, 20}, {Claus, 30}} );
  echo( [List: Name, 2] );          // Bea
  echo( [List: Name, Amy, Score] ); // Amy's Score: 10
  echo( [List: Name, ..] );         // All names in a parameter set
RHS Examples with variables
a[]                     10  "10"                   (numeral,full access)
colors                  4 elements:                (parameter set,full access)
                          red                        (softquoted string)
                          yellow                     (softquoted string)
                          green                      (softquoted string)
                          blue                       (softquoted string)
four                    4                          (plain numeral,full access)
name                    My Name                    (softquoted string,full access)
nine                    9                          (plain numeral,full access)

RHS Examples with a table
Bea
10
{'Amy','Bea','Claus'}
Try it yourself: Open LAN_Features_Right-Hand_Side_Expression.b4p in B4P_Examples.zip. Decompress before use.

See also

Left-Hand Side Expressions
Expressions