table assign

Prev Next

Function Names

table assign

Description

This function assigns a value one or more table destinations which is are specified in the 2nd and further function parameters containing a code piece or string containing the assignment destination. Writing to different tables is allowed, including accessing multiple cells at once.



You can use table assign as a function call to branch off an intermeditate calculation into a separate variable. The value in the destination immediately available while calculating the expression is still in progress, i.e. you can use the assigned destination further to the right in side the expression. See example further below.

Call as: procedure

Restrictions

Indirect parameter passing is disabled

Parameter count

2

Parameters

No.TypeDescription
1
input
all types Value to assign

The specified value provided in this parameter will be assigned in the target table destinations.

2, ...
code
variable
:string
destination tables

Make sure to add a ':' in front of the string expression if you want to execute string. Ad-hoc operations are not allowed here.

Return value

TypeDescription
all types Value in 1st parameter is passed through the return value.

Useful when branching off an intermediate calculation in the expression into one or more table destinations.

Examples

table initialize( t, {{ Header 1, Header 2, Header 3, Header 4 }} );

with table( t, 1 )
{
       a[] = '[Header 3]';
       table assign   ( Contents 1, [Header 1]    );
       table assign   ( Contents 2, :"[Header 2]" );
       table assign   ( Contents 3, :a[]  );
       table assign   ( {1,2,3}, [t: Header 3, 2.. ] );
}
table assign ( 3 Rows, [t: Header 2, 2..4] );

// Assign to mulitple destinations
table assign ( 2 Items, [t:Header 4, 1],:'[t:Header 4, 2]');
table list(t);

Output

    0 : Header 1   | Header 2   | Header 3   | Header 4
    1 : Contents 1 | Contents 2 | Contents 3 | 2 Items
    2 :            | 3 Rows     | 1          | 2 Items
    3 :            | 3 Rows     | 2          |         
    4 :            | 3 Rows     | 3          |         

Try it yourself: Open LIB_Function_table_assign.b4p in B4P_Examples.zip. Decompress before use.

See also

assign
exec
calc