Bug, variable L1 is changed by setting an other variable

Exploring the possibilities of using list-blocks to polish data from SDcard I experienced a very strange behaviour of the SET-variable block.
L1, L2, L3, L4 and L5 are shown as label text.
First I assign a value to L1 with MAKE-list; Label1 shows the contents.
Further on I assign a value to L3 with SET-to GET-L1; Label3 shows the content of L3.
In Label6 I set the value of L1. Enabling or Disabling the setting of L3 changes the contents of label6 !!!. :thinking:
list_append.aia (5.3 KB)

I don't really understand what the App is to achieve but I can see errors in the List assignments.

You have discovered that AI2 lists are linked lists.

It gets wierder. See this sample

1 Like

You can't Set a List with another List. You must use the copy list Block.

OriginalInit :heavy_multiplication_x:

Init :heavy_check_mark:

1 Like

I think,

set list3 to get list1

works

I think it might, depending on the content, but is unintended? Else copy list would be a redundant function.

Thank you all for the reactions!
Thank you @ABG for sending links with explanations. I understand how the strange behaviour can show up now.
The practical solution from @ChrisWard works fine. So I can continue studying how I have to program with AI.

This is just curiosity to check if

set list_4 to get list_3

is equals to

list_5 copy list list_3

borrar_lista22.aia (3.0 KB)

Wonderfull example Juan!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.