dim / redim protect

Prev Next

Function Names

dim protect, redim protect

Description

These two functions work similarly like dim() and redim(), but will also apply protection settings on all member variables. It may be useful to choose protection setting limited access in order to avoid accidental type changes on the array members. No impact on protection settings on already existing array members with the redim protect function. Here only the new members will be applied with the new protection setting.

Call as: procedure

Restrictions

Indirect parameter passing is disabled

Parameter count

4, 7, 10, etc.

Parameters

No.TypeDescription
1
input
string Protection setting

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

2, 5, 8, ...
code
variable
:string
Variable name

The array will be built on the specified variable. Member variables of existing arrays and structures are allowed so you can build more complex data structures.

3, 6, 9, ...
input
numeral
set of numerals
Dimension

Following types are supported:

numeral A one-dimensional array will be created.
parameters set of numerals A multi-dimensional array will be created, depending on number of elements specified. No array will be defined if an empty set is provided.

4, 7, 10, ...
input
valid types Initial value

The initial value will be applied for every variable member.

Examples

       dim protect( limited access, a[], 5, 123 );
       a[0] = 1;

       a[1] = Hi; // Will issue an exception
       echo("Test");

Output

Row #: Code Text _______________________________________________________
       1:     dim protect( limited access, a[], 5, 123 );
       2:    a[0] = 1;
       3:
       4:    a[1] = Hi; // Will issue an exception
                          ^
Inside the started program code:
Assignment on variable with limited access and type numeral
with value of type string is not allowed
Failed to access variable, protections apply.
Code execution will stop.  Going to interactive mode
________________________________________________________________________

Type 'help' for help, 'docs' for B4P docs, 'web docs' for online docs.
>>
Try it yourself: Open LIB_Function_dim_protect.b4p in B4P_Examples.zip. Decompress before use.

See also

dim
redim
array protect
insert members