insert members (protect)

Prev Next

Function Names

insert members

Description

insert members inserts a defined number of additional members with initial values into a specified location of an existing array. The members below will be shifted downwards.

Note:Inserting multi-dimensional arrays (similar to dim() and redim() is not supported here. You need to do this in a separate step afterwards.

Impact on base variables: The base variable remains unaffected. These functions affect the members only.

Call as: procedure

Restrictions

Indirect parameter passing is disabled

Parameter count

4-5

Parameters

No.TypeDescription
1
code
variable
:string
Variable name

The specified variable must be an existing array. Structures (with named members) are not allowed.

2
input
numeral Location

Specify the array location (array index) where the additional members need to be inserted.

3
input
numeral dimension

Specify number of members to add, beginning at the location specified in the 2nd function parameter.

Default value: text
4
input
valid types Initial value

The initial value will be applied for every new variable member added.

Opt. 5
input
string Protection setting

The supported protection settings are defined in the description for the function protect().

Default value: full access

Examples

  values[] = { 0, 11, 22, 33, 44, 55, 66, 77, 88, 99 };
  a[] = This is the base variable;

  array( a[], values[] );
  blank[] = {x,Blank};

  insert members( a[], 2, 3, 'Hi!' );
  insert members( a[], 3, 2, '2xHo!', prevent deleting );

  see(a[]);

Output

a[]                     This is the base variable    (softquoted string,full access)
Array [   0]            0  "0"                     (numeral,full access)
Array [   1]            11  "11"                   (numeral,full access)
Array [   2]            Hi!                        (softquoted string,full access)
Array [   3]            2xHo!                      (softquoted string,prevent deleting)
Array [   4]            2xHo!                      (softquoted string,prevent deleting)
Array [   5]            Hi!                        (softquoted string,full access)
Array [   6]            Hi!                        (softquoted string,full access)
Array [   7]            22  "22"                   (numeral,full access)
Array [   8]            33  "33"                   (numeral,full access)
Array [   9]            44  "44"                   (numeral,full access)
Array [  10]            55  "55"                   (numeral,full access)
Array [  11]            66  "66"                   (numeral,full access)
Array [  12]            77  "77"                   (numeral,full access)
Array [  13]            88  "88"                   (numeral,full access)
Array [  14]            99  "99"                   (numeral,full access)

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

See also

dim
redim
dim protect
redim protect
array