With the following :
DEBUG "Looking for message : "+rMessageID%+"\n"
FOREACH message IN messageList[]
DEBUG "Message ID : "+message.messageID%+" "+rMessageID%+"\n"
IF message.messageID%=rMessageID%
DEBUG "Deleted message 1 : "+rMessageID%+"\n"
DELETE message
DEBUG "Deleted message 2 : "+rMessageID%+"\n"
RETURN TRUE
ENDIF
NEXT
DEBUG "Message not found : "+rMessageID%+"\n"
RETURN FALSE
I find the following debug messages are displayed :
QuoteLooking for message : 21
Message ID : 21 21
Deleted message 1 : 21
Message not found : 21
Am I right in assuming that DELETE will force the message loop to continue onto the next array item or does it immediately break out of the loop ?
The important thing is that anything after DELETE wont be executed.
Indeed - I dont see why code after DELETE shouldn't execute - unless its protection against trying to use the type when it would no longer exist.
Apparently, it does a CONTINUE afterwards... So its not a bug :)
Nothing after a DELETE gets executed, it directly starts over with the loop.
Yes - comes of not looking the details for the command :)
About the inside:
FOREACH a in arr[]
PRINT a, 0,0
DELETE a
NEXT
Will produce:
for(int foreacha=0; foreacha<BOUNDS(arr,0); ) // make a loop for each element in arr[]
{
DGInt& a=arr(foreacha++); // Get a reference (pointer that is) to arr[foreacha]
PRINT( a, 0,0);
DIMDEL(arr, --foreacha); continue; // the delete removes the element at that position, continuing at the position after that element
}
So, as you can see "a" is only a pointer and after a DELETE it points to nothing (or is broken). Thus the "continue".