2014년 11월 27일 목요일

Need help for using "Replace list item list" with for item loop


Hello, I am a beginner to learn App Inventor 2. I try to make a little project that can replace one of the item in list.

But there are something out of my expectation, hope somebody help me to fix the problem.


Here is the sample:
I set two lists, called Gain_List, Pay_List.
Gain_List = [-1, -2, -3]
Pay_List = [1, 2, 3]

 Variables.PNG
Then I wanna replace the item of index 2 in Pay_List to 0 after I click the button, in double for item loop (for each Gain in list : Gain_List ; for each Pay in list: Pay_List )
And I wanna see the index of Items every loop.  

My expectation of result on ListView after finishing the double "for item loop",       
    Gain   Gain_index    Pay    Pay_index
       -1          1              1              1
       -1          2              98             2
       -1          3               3             3

       -2          1               1             1
       -2          2              98            2
       -2          3               3             3

       -3         1                1             1
       -3         2                98            2
       -3         3                3              3

=========================
The result after click button:
    Gain   Gain_index    Pay    Pay_index
       -1          1              1              1
       -1          2               2             0
       -1          3               3             3

       -2          1               1             1
       -2          2              98            2
       -2          3               3             0

       -3         1                1             1
       -3         2                98            2
       -3         3                98            2

How come the result will be like this??
I thought that the "replace list item" will immediately replace the Pay item  in the list.
Can anyone tell me how the "replace item in list" work?

 Body1.PNG

 Body 2.PNG

--
this looks very complicated...
but at least you tried to simplify the problem a little bit... Replace items between two lists after calculate the items each other list.
one issue you could check is: Pay is the list item itself and not the index... same for Gain...
see also How to work with Lists by Saj

 Unbenannt.PNG

--
Could you explain more what you are trying to do?

Why are there three rows in each group in your example?
What is the relationship between the first, second, and third row in each group?

Why are there three groups?
What is the relationship between each group and its next group?

--
It's one part of my project. It's hard to explain how I need to extract the index here in short sentences.

This link is all of my steps about this project, my problem will be on Page.7 (Part: Calculate The Items Between two Lists) 

The X.aia file is here:

The index stands for person here, thus I have to extract the exact index from the list.

For example, index 3 = person C , index 4 = person D

If you guys have any suggestions, I will really appreciate it! (my deadline will be on next Monday...

--
I set up a couple of fusion tables to show a better data model.

You could summarize charges and payments using SQL and
the Fusion Tables interface.

Try the Pizza Party tutorial if you're up to it.

--
The tables aren't sharing easily.

See the 2 screen shots for their shapes.

 Screenshot 2014-11-25 19.38.09.png


 Screenshot 2014-11-25 19.37.51.png

--
Thanks for ABG's suggestion. Using the database is a great idea. At first, I tried to build a app can be off-line used. Because it is a Go Dutch App, if the user can still utilize this App in area without Internet will be better
But my deadline of this project is coming soon, I will probably fix this trouble with Database http://austonabc.appspot.com/ (because it's free...but I have to drag some codes to build the table).

--
If you want to do it offline, here's a link to a doc on how to filter
lists of lists.  It can be extended pretty easily to include routines
to summarize tables too.


--
Thanks for ABG'S quick response. I already solved my problem.

--

댓글 없음:

댓글 쓰기