I have a TAG List called Offers. In this list I have 5 products, I need to know in which position of the list Offers is one of the products. So that I can in another procedure use this position.
I’ll explain further: When I change a value of a product that is in the Categories Tag, I also have another procedure that if this item is on offer, other blocks are triggered, and then the data of the product that is in that Offer Tag is changed. In order for the Block (Replace list item) to work, I have to put in the (Iten) the index of the product that is in the Tag List Offers. But in the product edition I’m on the TAG Categories List, got it?
you might want to use the index in list block
http://appinventor.mit.edu/explore/ai2/support/blocks/lists#indexinlist
Taifun
Explain better what I need. I have 2 ListView 1 and 2.
List View1 acts with a list called (Products). ListView2 acts with a list called (Offers). I want to click on the product chosen in listView1 and make the modifications normally, and within these modifications, I need to create a procedure for the product to also modify the List (Offers) that is viewed by ListView2.
So for this I need to know what is the position of the Product that is in the list (Offers), so that I can use inside the block below.
To make you understand even better, when I modify a product that is in listView1, it is clicked on FireBase to get the List (Products). But you will also get the list (OFFER). So I will have the 2 lists at the same time stored in different variables. So as I own the Offer List, I need to know where the product I am changing is. For this I have several text boxes and one of them would be the barcode. So if in this list Offers have more than 1 product, I have to know your position in the list to use in the block below.
See I’ve left a block missing, so you can understand it better. If I happen to have your position in the Offers list, and that position is number 3, then I just had to put a text box there and type in number 3. But I want it to be done automatically without me typing anything.
And before I answer, I can’t use the same product position as it is in litView1, because it’s different positions. Because I can have in the Offers list 100 products and in the Offers list only 5 products on offer.
sorry, but I didn’t understand your logic…
are the offers also products?
Taifun
Yes they are products. See I have in firebase 2 lists. Therefore, I need to replace a product in the Amino list with the same product list, which also has the same product, to receive the change. That’s why in the block I need to enter the position that the product is in the offer list. If I do this manually, knowing the position that the product is in the offer list, then I just had to create a text box on the app screen and there. position 1, 2, 3 or 4 would be informed. But I do not want that, I would like the system knowing the name of the list to be changed, in this case Offers, and knowing the product code, in this case 003, find in which position it is and thus can change the fields.
I want to avoid entering manually as described below.
Since the Offer List has a code 003, because each product has a unique code, then would it be possible with this to know the position that the product is within the list? So I would use this information within a variable and put it here:
Every time I change the offer value in the Unilife list, then in the offer list this offer value will also change, understand?
resume:
How do I find out where a particular product is in a list containing 10 products?
see again my first answer
Taifun
I saw and reviewed more sorry did not understand, how should I change the blocks? Could the friend help me?
The blocks are there only help me to assemble what is missing.
use the index in list block, in the thing socket you add your product name, in the list socket your list, see also the documentation AI2 Lists
if the value you get is 0, then the product is not in the list, else you get the index back
you might want to try something and if you get stuck, post a screenshot of your relevant blocks…
Taifun
Thank you very much, I will try to do as you explained, and if I can’t, then I’ll post here the main blocks of this operation.
What I want is to find the product position, which in this example would be the barcode \ "7898917294505 " in the list below.
“[[” 003 \ ", " 7898917294505 \ ", " Uni Maca Peruvian Powder \ ", " \ ", " 150 g \ ", " \ ", " \ ", " Energy & Vigor \ ", " Unilife \ ", " 35.00 \ ", " 20 \ ", " 1 \ ", " https: \ / \ / firebasestorage.googleapis.com \ / v0 \ / b \ / do-well-3d183.appspot.com \ / o \ / 7898917294505? alt = media & token = 164e32d1-17f8-4cbe-a006-45da70bf5558 \ “], [” 537 \ ", " 7898483537716 \ ", \ "Uni Luteina ", \ “”, \ "60 Caps ", \ “”, \ “”, \ "Natural ", \ "Unilife ", \ "49.90 ", \ "\ ", " 2 \ ", " https: \ / \ / firebasestorage.googleapis.com \ / v0 \ / b \ / do-well-3d183.appspot.com \ / o \ / 7898483537716? alt = media & token = 802d3f5c-e80c-4c43-8ca9-b9e6496a4b84 \ “]]”
Note that in this list there are 2 products, with the first product, "003 ", \ "7898917294505 " being in position 1 of the list, and the second, [\ "537 ", \ "7898483537716 " position 2 of the list.
So I need to know in which position is the product I will be modifying, whether in position 1 or position 2. I need this exact location for the replacement to be correct in the block below.
I want to point out here that the modification is being made to another List, and I am just making the Offer List change if the Offers text box is different from Empty.
Note that I put (1) in the Index position. If you had placed (2) then it would be the second product on the list that would be modified. Beside is the block that I understood to be what you wanted to explain.
I need then, not there (1) but something that would search the Offer List, find the Barcode that is unique for each product, and with that find the position of this product in the list, take that position and put it right there. where I put number 1.
Doing it manually, putting (1) works all right. But it cannot be manual, as it will not always be (1) it can be for example the position 10 of the Offers list, if this list contains 10 items.
are you saying, the barcode is no unique key?
you will have to write a custom procedure then
Taifun
and how would this procedure be personalized? would you please describe the blocks here?
sorry, that i not just a simple answer, you have to translate what you described previously in blocks
see also AI2 Procedures and Procedures
Taifun