Click or drag to resize

ArrayDeProtectT Function (Array OfT)

X#
Removes write protection from an entire array.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.21
Syntax
 FUNCTION ArrayDeProtect<T>(
	aTarget AS ARRAY OF<T>
)
 AS LOGIC
Request Example View Source

Parameters

aTarget
Type: Array OfT
The array to deprotect.

Type Parameters

T
The type of the array elements

Return Value

Type: Logic
TRUE if the array was successfully deprotected; otherwise, FALSE.
Remarks
ArrayDeprotect() removes the protection placed on an array by the ArrayProtect() function, allowing their values to be changed.
Examples
This example stores values to array elements, protects the elements, then removes the protection so they can be changed:
X#
 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    // Write allowed in calling function
 8    ArrayPut(aWriteProtect, 1, "Main Function")
 9    // Write not allowed in called function
10    TryChange(aWriteProtect)
11    ArrayDeprotect(aWriteProtect)
12    // Write allowed (no protection)
13    TryChange(aWriteProtect)
14FUNCTION TryChange(aPassed)
15    ArrayPut(aPassed, 1, "Sub Function")
See Also