Array creation and check. AC 800M Control Builder Code
When using DeleteArray, Createarray, InsertArray or GetArray is status returned from the function.
To build robust code what action is appropriate if returned status not is Success=1?Is that to try again with the same call or do you need to "clean up" after un successful call? If so, what kind of "clean up" must be done?
If possible, I would try to avoid using arrays. But sometimes it is ncessary. From my experience of using them they seem to be quite robust as long as you have created the array correctly.
- Your CreateArray should be in a Start_ block of a Control Module.
- If you are using arrays in Program POUs where the Start_ code block does not apply then put your CreateArray inside an IF-THEN statement ...
if not Init then
init:= true; (* Init is a Boolean with retain = BLANK and initial value = false *)
I dont think you should ever need to delete an array. If you never delete the array then you will never have problems with the array not existing. If you try to create an array that already exists, then nothing happens. The array still exists.
If you get a status code other than 1 from any operation (other than CreateArray when the array already exists), then your code is wrong. Dont try to handle the error code - fix the problem.