for all characters

Prev Next

Function Names

for all characters

Synopsis

for all characters( string value, iterator value, iterator counter ) statement;
for all characters( string value, iterator value, iterator counter ) {statements; }

Description

The loop works through all elements in the set provided in the 1st function parameter. If the 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
string parameters

Elements in this 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 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 characters( Hello, greetings[] ) print( "   Say: ",greetings[]);

Output

   Say: H   Say: e   Say: l   Say: l   Say: o
Try it yourself: Open LIB_Function_for_all_characters.b4p in B4P_Examples.zip. Decompress before use.

See also

for all variables
for all

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.