Parameter Sets Specifying Members

Prev Next

Introduction

Variable members can either be specified with constant values, and expressions such as variables. This provides flexibility, but sometimes you need the flexibility to access different members in differently deep levels dynmically. This is best done with using parameter sets which make up a part of the sequence of member names and/or index numbers or the whole one. See the following example:

  var[me,you,we,they] = those people;
  var[me,you,we,us] = we the people;
  var[me,you,we] = all of us;
  var[] = grandfather;

  a[] = you;
  b[] = we;
  echo( var[ me, a[], b[] ] );

  c[] = { you, we, us };
  echo( var[me, c[]] );   // Use parameter set to specify sub-members behind 'me'

  c[] = {me} + c[];
  echo( var[c[]] );   // Use parameter set to specify all nested members

  c[] = c[]{0..2};    // me, you we only
  echo( var[c[]]  );      // Use paramter set to specify first part of all nested members

  echo( var[ {} ] );  // Empty set refers to base variable
  echo( var[ {}, {me, you}, {}, {we, they} ] );   // Combinations like this one are OK
  // Empty sets in the middle of the 'path' are considered as 'same location'

Output 01

all of us
we the people
we the people
all of us
grandfather
those people
Try it yourself: Open LAN_Features_specifying_members_with_parameter_sets.b4p in B4P_Examples.zip. Decompress before use.