Problem replace item list

43 views
Skip to first unread message

Tnn

unread,
Jan 25, 2019, 3:21:23 AM1/25/19
to mitappinv...@googlegroups.com

i,

a strange thing …


I explain, because doing REPLACE of an ITEM in the lstTrattSell list at position 1,


it also changes the item to the same position in the list lstDbDefault ???


Immagine3.jpg



so instead it works ...

why???

the first block does not have to do the same thing ???


Immagine4.jpg




TimAI2

unread,
Jan 25, 2019, 5:19:40 AM1/25/19
to MIT App Inventor Forum
That is what you are asking the blocks to do :)

In your first image you are replacing the entire list of lists in lstDbDefault with what is in lstTrattSell, because "position 1" is the first "make a list" block

In your second image, you are also replacing everything in the the first list of lists

Please explain what you want to achieve, then we can help you sort your blocks out

(it may also help if you make a decision on which AppInventor you are going to use, if AI2 then ask here, if Thunkable / other, then ask on their forums)

Tnn

unread,
Jan 25, 2019, 5:46:42 AM1/25/19
to MIT App Inventor Forum
I do not understand, because if I modify an item in lstTrattSel, which is a separate list

it also changes the item in the lstDbDefault list ???

Immagine6.jpg


TimAI2

unread,
Jan 25, 2019, 7:02:25 AM1/25/19
to MIT App Inventor Forum
I am not seeing an issue ?

correctlist.png


Tnn

unread,
Jan 25, 2019, 8:34:21 AM1/25/19
to mitappinv...@googlegroups.com
So there's a problem somewhere ...

because I running the code instead I have this:

Immagine33.jpg




TimAI2

unread,
Jan 25, 2019, 9:10:27 AM1/25/19
to MIT App Inventor Forum
Do it like this:

correctlist2.png


Seems there is a pass through from the first list by selecting an item that is a list

Creating a new list from the list items fixes this. Confusing, but there is some logic in there somewhere.


ABG

unread,
Jan 25, 2019, 9:32:18 AM1/25/19
to MIT App Inventor Forum
This looks like a good place to use the copy list block.

It is for when you want to make a new list with a copy
of another list, and for each of the 2 lists
to have lives of their own, one independent of the other.

ABG

Tnn

unread,
Jan 25, 2019, 9:34:03 AM1/25/19
to MIT App Inventor Forum
yes, I had already used this solution ...

oh well ... I am perplexed!

Taifun

unread,
Jan 25, 2019, 4:45:11 PM1/25/19
to MIT App Inventor Forum
I explain, because doing REPLACE of an ITEM in the lstTrattSell list at position 1,
it also changes the item to the same position in the list lstDbDefault ???

this behavior is called call-by-reference
to copy a list use the copy list block

Taifun 

Trying to push the limits of App Inventor! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun. 

Reply all
Reply to author
Forward
0 new messages