for all parameters

Prev Next

Function Names

for all parameters

Synopsis

for all parameters( parameter set value, iterator value, iterator counter ) statement;
for all parameters( parameter set value, iterator value, iterator counter ) {statements; }

Description

The loop works through all elements in the parameter set provided in the 1st function parameter. If the parameter set is empty, then the loop will not be executed. This loop will not step into nested parameter elements.

Call as: procedure

Restrictions

Indirect parameter passing is disabled

Parameter count

2-3

Parameters

No.TypeDescription
1
input
parameter set
string
parameters

Elements in this parameter set will be provided. If a softquoted string is provided, then the contents separated by commas are individual elements. If the string is a quoted one, then it will be treated as one element. Empty parameter sets (and string: '') make the loop skip.

2
code
variable
:string
iterator value

This variable is updated by this function in order to provide the value of the current parameter element. It is a copied value. Modifying this variable will not influence the loop

Opt. 3
code
variable
:string
iterator counter

This variable is updated by this function and provdes the index. It always begins with 0 and continues with 1, 2, etc.

Examples

      for all parameters( { He, Hi, Ho }, greetings[] ) print( "   Say: ",greetings[]);
      echo;
      for all parameters( 'He,Hi,Ho', greetings[] )     print( "   Say: ",greetings[]);
      echo;
      for all parameters( "He,Hi,Ho", greetings[] )     print( "   Say: ",greetings[]);
      echo;
      a[] = {A..C};
      for all parameters( a[], greetings[], i[] )     print( "   Say: ", i[], ":", greetings[]);

Output

   Say: He   Say: Hi   Say: Ho
   Say: He,Hi,Ho
   Say: He,Hi,Ho
   Say: 0:A   Say: 1:B   Say: 2:C
Try it yourself: Open LIB_Function_for_all_parameters.b4p in B4P_Examples.zip. Decompress before use.

See also

for all variables

Notes

Manipulation while inside the loop:
1. The iterator cannot be manipulated. It will be overwritten at the next loop round.
2. If the iterator is deleted inside the loop, it will be reinstated at the next loop round. This applies to all loop variables.
3. If the target variable name is deleted, or its members are deleted / added, then the loop will end. If some of the members are removed, it will have an impact such as fewer loop cycles. Since the members are sorted in alphabetical order, the whole list of members may shift accordingly. Therefore I recommend not to manipulate this variable while inside the loop. Inside the loop: If the affected variable is deleted or a member variables removed, then the loop will do a premature end.