protect, protect recursive
This function applies a protection setting on the variables. Protection can only be applied on local variables only if running in a local variable context (e.g.
inside a user-function or running a B4P file started from another B4P file using start() or include(). Exceptions can be enabled using global().
Changing protection on a system variable is not possible at all and any time.
Attention: If protecting a member variable, do not forget to protect the parents, too (If parents are in danger, then the members are, too, even if they are protected).
The "protect recursive" call will apply the protection setting to all member variables.
Note that "protect recursive (check)" only checks protection settings in the base variable.
Note: Member variables created after protection settings made do not inherit any protection settings from their parents. full access is assumed initially.
Indirect parameter passing is disabled
Min 2
No. | Type | Description | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 input |
string | Protection setting Following protection settings are available:
| ||||||||||||||
2, etc. code |
variable :string |
Variable to protect |
Type | Description |
---|---|
string | Polled protection setting The protection setting of the 1st variable is returned. |
b[] = 2;
b[Hi] = 3;
b[Ho] = 4;
protect( read only, b[] ) ;
echo( "Base variable protection setting: ", protect( check, b[] ) );
see( b[] );
protect recursive( prevent deleting, b[] ) ;
echo( "Base variable protection setting: ", protect( check, b[] ) );
see( b[] );
b[] = 2;
b[Hi] = 3;
b[Ho] = 4;
protect( read only, b[] ) ;
echo( "Base variable protection setting: ", protect( check, b[] ) );
see( b[] );
protect recursive( prevent deleting, b[] ) ;
echo( "Base variable protection setting: ", protect( check, b[] ) );
see( b[] );
Base variable protection setting: read only
b[] 2 "2" (numeral,read only)
Hi 3 "3" (numeral,full access)
Ho 4 "4" (numeral,full access)
Base variable protection setting: prevent deleting
b[] 2 "2" (numeral,prevent deleting)
Hi 3 "3" (numeral,prevent deleting)
Ho 4 "4" (numeral,prevent deleting)
Base variable protection setting: read only
b[] 2 "2" (numeral,read only)
Hi 3 "3" (numeral,prevent deleting)
Ho 4 "4" (numeral,prevent deleting)
Base variable protection setting: prevent deleting
b[] 2 "2" (numeral,prevent deleting)
Hi 3 "3" (numeral,prevent deleting)
Ho 4 "4" (numeral,prevent deleting)