You can allocate arrays
of specific type and size with the __NEW(type, size)
method and then free the memory with __DELETE(pointer)
method as in the code below:
METHOD myCode
VAR_INPUT
myArray : POINTER TO INT;
END_VAR
myArray := __NEW(INT, 10); // Create array of type INT with size of 10
__DELETE(myArray); //Free the memory
myArray := __NEW(INT, 20); // Allocate new memory now with the size of 20
__DELETE(myArray); //Free the memory
END_METHOD
- Be careful with this because you need to free the memory with the
__DELETE(pointer)
method!
- Note that you can't change the size of array if you declare them statically like in your answer.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…