2017년 1월 2일 월요일

Help "Select list item: Attempt to get item number 1 of a list of 0:()" quiz app


I am making a quiz app with 4 multiple choice answers and I don't manage to find where the error is in the blocks.
Everytime the app is launched, this message appears : 
"Select list item: Attempt to get item number 1 of a list of length 0: ()" .
I have tried a lot of solutions but for the moment nothing works.

Could you please help me to find a solution ?
You could find an attached file with all the blocks.




If you are asking for help, I recommend you to make it as easy for others to be able to help you ...
You probably will get more feedback then...

which means in your case post a screenshot of your relevant blocks...


To download the aia file, upload it to  App Inventor, open it, do some bug hunting for you, etc... this takes time, and most people will not do that...

-- 
Your blocks look clean and well conceived.
From reading your blocks, I don't see any obvious error, except for starting Screen1 from the game over procedure.
Closing Screen2 seems more reasonable at that point, to return to Screen1.
See the Screens section of this FAQ for alternative screen handling techniques...

--
Maybe you should also post a copy of Screen1's blocks too?

-- 
In the New Question procedure, you test if you still have another question to ask.
If you do, you ask the next question and increment the index.

Afterwards, you act like the game just ended, after a single question.

You are missing an ELSE branch for that IF more questions block.
Use the blue mutator to add it,
and move the gameover call into the ELSE socket.
.
You might still have a problem in that gameover procedure,
but this should get you thru the first 3 questions.

-- 
Thanks a lot for your help.
I have added an ELSE and moved the "gameover call" as you suggested and the error message doesn't appear anymore !!
However, all the asnwers appear at the end of the quiz and I would like each answer to appear after each question.
Do you know how is it possible to realize that ?

-- 
Take the two big green statements that set the response correct text and background color,
and move them from their current location into the response procedure.

-- 
Perfect !
But the answer to the first question appears under the second question.
Do you know if there is a way to make the answer appear under the linked question?
Thanks a lot !!

-- 
Since you did not post any blocks, I will have to guess blindly...

Did you increment the question number before or after posting the answer?

-- 
I guess that I increment the question number before posting the answer....
You could find the blocks in the attached file.

Blocks App Apothicaire.pdf

-- 
I don't see the problem.
It seems that it should work.
I see that you are using a ListYourAnswer list to store the answers. Why?
You can just reuse the local YourAnswer for each question instead unless you plan on using that list for something else later on. 

-- 


댓글 없음:

댓글 쓰기