Forums / General / Array append Problem / Comment29725

Author Topic

Rinze Cats

Thursday 10 June 2004 5:01:11 am

Comment29725

Mm, runnig into some weird behaviour again, do any of you have an explanation for this?

The code should first initialize an array, then it should dynamically at items to this array, if the item doesn't already exist. The general idea is to fetch an objects position value, or assign the first available position number randomly, if the position is missing from the current object.
The second part of this code snipplet is behaving really weird

{let my_array=array()}
{section var=Container loop=$current_node.object.related_contentobject_array}
{section show=and(ne($Container.data_map.positie.content.0,''), ne($Container.data_map.positie.content.0, '0'))}
	{set my_array=$my_array|append($Container.data_map.positie.content.0)}
{/section}
{/section}

{section var=counter loop=20}
	{section show=$my_array|contains($counter)}
		{* do nothing *}
	{section-else}
		{set my_array=$my_array|append($counter)}
	{/section}
{/section}
{/let}

When I omit the section-else part, the function works. With the {section-else} part, it doesn't. The else part is executed once, an item is added to array. So far so good. However, now the {section show=$my_array|contains($counter)} always evaluates to true, and the new element in the array is updated with the value of $counter (although the else part of the loop is isn't executed??).

I am at a loss here.