The functions protect(), dim protect(), redim protect(), array protect(), and structure protect(__) are available apply protection rules on the target variables. It is always possible to change protection settings on local variable. For global variables, this is only allwed in the global context (i.e. not in the code of user-defined procedures and functions and B4P programs started with start() or include()). Protection settings of system variables cannot be altered. If not specified otherwise, all newly created variables bear the protection setting full access. The follwoing table provides an overview of the available protection settings and their functional impacts:
Protection Settings | full access | prvent deleting | limited access | read only | locked | tightly locked |
---|---|---|---|---|---|---|
Read variables | ✔ | ✔ | ✔ | ✔ | - | - |
Read member variables 1 | ✔ | ✔ | ✔ | ✔ | ✔ | - |
Use as input parameter to functions | ✔ | ✔ | ✔ | ✔ | - | - |
Write variables | ✔ | ✔ | Data of same type only 2 | - | - | - |
Write member variables 1 | ✔ | ✔ | ✔ | ✔ | ✔ | - |
Use as I/O paramters to functions | ✔ | ✔ | - | - | - | - |
Delete varibles | local variables only | - | - | - | - | - |
Create / add member variables | ✔ | ✔ | - | - | - | - |
Modify variable forms 3 | ✔ | - | - | - | - | - |
Create arrays | ✔ | ✔ 4 | - | - | - | - |
Do Transactions | ✔ | - | - | - | - | - |
Use protect() to check settings | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
1 Provided no additional protection seetings restrict usage of the member variables.
2 E.g. forbidden to overwrite string contents with numeric contents. Additional restrictions may apply on system variables, e.g. only specific values may be written.
3 E.g. converting structures to arrays and back using array to structure() or structure to array() functions.
4 Only possible if variable contains no other members so far.
Variables may be temporarily locked with blocking notices in order to prevent adverse system behavior if they are deleted. All other accesses are possible. Blocking notices are temporarily applied in following cases:
Only if all block notices are removed again (assignment resp. transactions completed, function execution finished, references released), then the variable may be deleted again.