2017년 3월 24일 금요일

How to make the program wait for either a yes or no response from a Notifier


Can I use a notifier to display a message and make the program pause until the notifier is acknowledged?
As it is the program continues running with the notifier on screen 

--
I'm hardy experienced, so there probably is a way, but in case there isn't you could set a global variable.  If the global variable is false, don't run code.

-- 
I ran a test of the Notifier Choice block, with a Clock and a bouncing ball.
Neither stopped.

So you have to keep track of all your moving parts and stop them yourself.

See attached for The World's Dumbest Number Guesser app.


Capture.PNG 표시 중


--
App Inventor will never wait...

use the Notifier.ShowChooseDialog and continue your logic in the AfterChoosing event

--
If App Inventor will never wait what is the point of having When Notifier1. AfterChoosing if it never waits for an answer

-- 

IApp Inventor will never wait what is the point of having When Notifier1. AfterChoosing if it never waits for an answer
It's all about having an answer to the choice question, not about waiting.


So if the question is "Should I Quit?"  the Quit block would
be in the AfterChoosing event block, guarded by a test for "Yes" reponse.

You weren't considering putting the Quit block after the block where you ask the question,
were you?

-- 
No, The programs asks 30 questions, after every question is read out by the program it checks the answer given and if correct the score is increased by one, when the score hits multiples of 10 i want a popup notifier to appear and the program to wait for the acknowledge button press from the notifier before asking the next question.

-- 
It's time for you to post some blocks.
Provide both a downloaded blocks image amd an exported .aia

-- 


-- 
(going offline for a day.  Throwing this thread up for any one available)

-- 
How about running the code to ask the next question in the notif's AfterPicking or whatever handler?

-- 
Like move the code in NewWord.Click to a function, then call that function in the AfterPicking handler as well.

-- 
the newword button is there to skip that question and move onto the next question so I have it set in the submit button function where it checks the answer

-- 
Okay.  First, why do you want two buttons, one with "O" and the other with the k?  Is there any specific reason?  I suggest using the block in screenshot two, which only displays one button.

Screen shot 2017-03-17 at 6.22.05 PM.png 표시 중

Screen shot 2017-03-17 at 6.22.14 PM.png 표시 중

-- 
I know this isn't addressing the issue you posted about, but in the notifier's afterChoosing handler you set the background image to a media file that isn't uploaded.  I think you forgot that there file.  ;)

Screen shot 2017-03-17 at 6.25.09 PM.png 표시 중

-- 
no particular reason, id actually prefer just one button but I could not get the one you posted to work either

-- 
I haven't fully looked over all the code, but since you're the author and probably know it backward and forward, how about calling the GetWord function from the Notifier's AfterPicking handler?  Do you think that would work?

P.S. I notice the set bronze, set silver, and set gold blocks have warnings.  I don't see them added to this screen.  Did you accidentally delete those components?

Screen shot 2017-03-17 at 6.27.59 PM.png 표시 중

Screen shot 2017-03-17 at 6.29.07 PM.png 표시 중

Screen shot 2017-03-17 at 6.29.10 PM.png 표시 중

Screen shot 2017-03-17 at 6.29.12 PM.png 표시 중

-- 
As for the notifier thing, perhaps the blocks I've attached would do the trick?

Screen shot 2017-03-17 at 6.30.55 PM.png 표시 중

Screen shot 2017-03-17 at 6.31.14 PM.png 표시 중

-- 
Works for me.  :D

When the screen initializes, the current word is not spoken.  Perhaps you can add a notifier:
Click the Okay button (the button in the notifier) when you're ready to begin.

And then you can call GetWord.

On a different subject, how about making a global variable and setting it to the listFromCsvRow[list in text here]?  Then you can use the list length block in your if statement in the GetWord function.

Screen shot 2017-03-17 at 6.34.27 PM.png 표시 중

-- 
the bronze silver and gold things are additional bits that are in the full app code and that part works without problem, what i posted is a cut down of my main program just to show the part I am having issues with.
And as for calling the getword function from the Notifier's AfterPicking handler that will not work as the notifier is only called when 10 answers have been input correct while the getword function is called to choose a new question

-- 
I thought that was what you wanted, to have the game go to the next word after the notifier is Okayed.  Sorry, I misunderstood you, I'm thinking.

-- 
I think the next step would be to explain, specifically, what you want to happen.

-- 
P.S.  Another question: Why do you have two TextToSpeech components?  Why do you need two?  Does one have a different setting or something?

-- 
the app asks questions and every 10 correct answers the notifier pops up, and the app should not ask the next question until the notifier is dismissed but for whatever reason the app still asks the next question while the notifier is active

-- 
use the Notifier.ShowChooseDialog and continue your logic in the AfterChoosing event
same for silver and gold

-- 
This may be just a bandage, but time the amount of time the notifier shows, and set and use clock component to wait until after the notifier's gone.

-- 
Nothing is being chosen, @Taifun.

-- 
Specifically, in submit.Click see if you're on a multiple of 10.  If so, switch the clock on and show the notif.  In the clock's handler for when the time ends, then go to the next question.

-- 
app
this is because you do not continue with the logic in the AfterChoosing event
you might want to take a look at the corrected screenshot here https://groups.google.com/d/msg/mitappinventortest/ROyJZEmXUgY/oeq8EzVgGgAJ

-- 
wont work because the notifier is only ever called when 10 CORRECT answers have been given not every questions

-- 
Well then try what I suggested when you're on a multiple of 10 correct.

Yes, sleeping on it may give you a fresh view tomorrow.  Good St. patrick's Day luck to you!

--
what about this pseudo code?

if 10th correct answer 
then open notiier.ChooseDialog
else continue with your logic

AfterChososing
  continue with your logic

the "continue with your logic" part could be a procedure...

-- 
But he's using alerts where there is no choosing.

--
OK after sleeping on it I have come to the conclusion that the notifier will simply not do what I was hoping it will do as the notifier if called within a loop allows the loop to continue running whilst the notifier is still visible on the screen, I am therefore going to try this from another approach, its a bit more complex for me to do but it might be possible, I will post back if it works or not

-- 

댓글 없음:

댓글 쓰기