ArrayProtect Function (Array) | |
Protect an array from change in all functions except the one in which it was declared.
Namespace:
XSharp.RT
Assembly:
XSharp.RT (in XSharp.RT.dll) Version: 2.21
Syntax FUNCTION ArrayProtect(
aTarget AS ARRAY
) AS LOGIC
public static bool ArrayProtect(
Array aTarget
)
Request Example
View SourceParameters
- aTarget
- Type: Array
The array to protect.
Return Value
Type:
Logic
TRUE if the array was successfully protected; otherwise, FALSE.
Remarks
ArrayProtect() protects array values from change once you assign values to them.
The function in which the array is declared can still write to the array.
Examples
This example stores values to array elements, protects the elements, then removes the protection so they can be changed by sub-functions:
1FUNCTION Start()
2 LOCAL aWriteProtect AS ARRAY
3 aWriteProtect := ArrayCreate(2)
4 ArrayPut(aWriteProtect, 1, "Origin")
5 ArrayPut(aWriteProtect, 2, "Origin")
6 ArrayProtect(aWriteProtect)
7
8 ArrayPut(aWriteProtect, 1, "Main Function")
9
10 TryChange(aWriteProtect)
11 ArrayDeprotect(aWriteProtect)
12
13 TryChange(aWriteProtect)
14FUNCTION TryChange(aPassed)
15 ArrayPut(aPassed, 1, "Sub Function")
See Also