2017년 4월 12일 수요일

Notification Message Show


Hello Gentlmen,
I Need some help, Please: 
I am working on an application "Math Book". There are 30 chapters, each chapter has 20 pages. I want a message pops up just when entering a new chapter: telling that you are in chapter 1,2,3 etc.


--
If all Chapters are the same length, just test the page numbers and when it is a multiple of 20 fire the notification, gathering chapter information for the message. You will need a list for this ;)

-- 
Thank you Mr.Carter for your kind reply.
I made a list for showing message of chapters after 20 pages because they have the same quantity of pages.
I tried to build the mathematics to fire notification but I don't know how.
Can you please give some hints.


-- 
OK, I have put together a simple example for you.

Assumes a title notification/page (Page 0) then Chapters every 3 pages. Have setup the swipe to change the colour of the background.

Should give you enough to go on. If you want to preserve the page number a reader has got to, you will need to use a tinydb to save the page.

You could do some clever logic with the counter and the list to keep the length of the procedure down.


-- 
You are a very helpful man. Thank you so much for great job.

-- 
I tested the blocks every things is fine when there is 30 chapters and make compile but when the total is 60 chapters and make compile there is message.:
App Inventor is unable to compile this project.
The compiler error output was
_____Preparing application icon
_____Creating animation xml
_____Determining permissions
_____Generating manifest file
_____Attaching native libraries
_____Copying native libraries
_____Attaching component assets
_____Compiling source files

I have tried so many times to change in blocks but it is the same problem
Can you please find out what is the problem?

-- 
This is too much data to keep in blocks.

Load the chapter_start_pages table from a csv
file in the Media folder.

Keep it as a 2 column csv table:
(starting page number, chapter title)

After loading it as a file then converting it to a table using
the appropriate csv block, it will be available for an easy lookup-in-pairs
block, taking the current page number and looking it up in that table.
If found, return the current chapter title, otherwise blank.

If blank, don't bother raising the Notifier.

You will have to learn how to load your book text and images into the Media Drawer.
There's no way to keep that much text in blocks.

-- 
Thank you Mr.Abraham Getzler
I don't know how to make the blocks because I am a very old man and have lack of knowledge to do that. please help me if you would like.





-- 
See the section on loading a puzzle table in this doc ...

-- 
Yes, Thank you Abraham for this useful subject,
I have made the block but how can I simply it to make it easier and shorter instead of make pChapter in 60 messages.

-- 
I get the feeling you are putting the cart before the horse in building this app.

You are trying to deal with chapter headings before you have dealt with the harder foundation problem
of how you will bring in your chapter text and illustrations.

That problem should be solved first.

Show us three complete chapters in your app loaded through files,
then it would be appropriate time to talk about chapter headings.

-- 
I have done it fine but when I make it empty also message is appeared even if it is blank. How can I make it not shown.





-- 
Catch the result of the lookup in pairs into a variable.
Then test the variable if it is blank.
If the variable is not blank, then
  notify, else do nothing.

-- 
The same problem when I try to catch the result of the lookup in pairs into a variable.
Can you please tell me what to do.


-- 

The same problem when I try to catch the result of the lookup in pairs into a variable.
Can you please tell me what to do


Start by reading what you wrote.

Where is the place where you change the variable blank's value?

And if you never change its value, when will that Notifier ever get called?

-- 
Would you please show me how can I catch the result of the lookup in pairs into a variable And how can I test the variable if it is blank. Because I can't move one step forward.

-- 
Let's start with the most fundamental step, necessary before any progress can be made.

Your variable names are wrong.

The effect of picking a wrong variable name can be catastrophic.

An example ...

You are walking down a dark alley, and you hear a cry for help.
You run and find a man on the ground, bleeding, with a knife in him.
You try to help him, getting bloody, and the police arrive.
They see you and arrest you, over your objections.
It's time for your trial by jury, and the officer in charge is making a label for
your chest, to identify you to the jury and the judge.
The officer has a choice between writing "murderer" and "suspect" on the label.
Do you see the difference this would make to the course of the trial?

So let's get back to the problem, and correct two crimes of nomenclature ...

The variable pairs  should be called page_headings,
because it is a table taking page numbers and translating them into headings.

The variable blank should be called heading because it is the result of 
looking up the heading for the current page number.

So go back and rename those variables, and take a new blocks image,
then look at it with new eyes and see if the new names help you 
see what will need to be done further.

Then come back here.

-- 
I did what you have said. But I don't know what is the next step





-- 
what about 
  set global heading to lookup in pairs...

my suggestion is to first learn the basics...

A very good way to learn App Inventor is to read the free Inventor's Manual here in the AI2 free online eBook   http://www.appinventor.org/book2 ... the links are at the bottom of the Web page.  The book 'teaches' users how to program with AI2 blocks.
There is a free programming course here http://www.appinventor.org/content/CourseInABox/Intro  and the aia files for the projects in the book are here:  http://www.appinventor.org/bookFiles  
How to do a lot of basic things with App Inventor are described here:  http://www.appinventor.org/content/howDoYou/eventHandling  .

Also do the tutorials http://appinventor.mit.edu/explore/ai2/tutorials.html to learn the basics of App Inventor, then try something and follow the
 Top 5 Tips: How to learn App Inventor

You will not find a tutorial, which does exactly what you are looking for. But doing the tutorials (not only reading a little bit) help you to understand, how things are working. This is important and this is the first step to do.

--
In the initialize global heading, set it to blank.
It is meant to be a piece of text, not a true/false value.

In the procedure, insert a new statement BEFORE the if/then test:

procedure pChapter
  set global heading to lookup in pairs ...   (move it from the Notify block)
  if global heading > " " then
    show alert (global heading)
  end if
end procedure

By the way, which tutorials have you done?
Not just looked at, but actually built with your fingers?
Even experienced programmers need to do the AI2 tutorials.

-- 
And follow Taifun's advice!

-- 
Thank you  too much Taifun and Abraham, I will read more tutorial and get more courses to learn about inventor.
I am really appreciate of your help and support me. please I need your help until finish this section.

-- 
I read so many texts about inventor but I could not find an example about this section. Could any one help me,please





-- 
inventor
you should do this now

where do you call procedure pChapter?
and if you want to check for global heading > 0 in your if statement, then I have to following question for you: why do you set the socket "not found" of the lookup in pairs block to an empty string instead of 0?



A very good way to learn App Inventor is to read the free Inventor's Manual here in the AI2 free online eBook   http://www.appinventor.org/book2 ... the links are at the bottom of the Web page.  The book 'teaches' users how to program with AI2 blocks.
There is a free programming course here http://www.appinventor.org/content/CourseInABox/Intro  and the aia files for the projects in the book are here:  http://www.appinventor.org/bookFiles  
How to do a lot of basic things with App Inventor are described here:  http://www.appinventor.org/content/howDoYou/eventHandling  .

Also do the tutorials http://appinventor.mit.edu/explore/ai2/tutorials.html to learn the basics of App Inventor, then try something and follow the
 Top 5 Tips: How to learn App Inventor

You will not find a tutorial, which does exactly what you are looking for. But doing the tutorials (not only reading a little bit) help you to understand, how things are working. This is important and this is the first step to do.

--
I really need help, Please

-- 
Are you sure that Page_No is just a page number ?

In my original example I added "Page: " to the counter. If you left this in your "flung" blocks, your pChapter code won't work.

I have it working nicely

here are the blocks:
-- 
Actually, I make file to read page number from csv as Abraham Said







-- 

I really need help, Please

you might want to elaborate, what exactly happens and what you like to happen instead

-- 
OK, get the app running in an emulator, then use "Do It" on your blocks inside pChapter, this should help you to see where things are going wrong?

Still can't see from the blocks you posted where Page_No is coming from?

-- 
I attached an example which is exactly the same of my project but when flung the page no there is problem I can't fix in this example but in my project there is no problem.
Please help me to know how to show the notification on page 2 and page 4. in my project there are 500 pages and 200 notification.
Thank you so much and I hope to accept the aia 


-- 
Attached is updated one


-- 
Had a look at your example - "chapter.aia"

I was able to make it work with some changes (these are not fixes) so I can tell you what is wrong / not coded correctly

Firstly your blocks to show the images > page1.png etc. You don't need the join block as the full filename is already in the variable.

You also were not calling the procedure pChapter anywhere so i added it to getPage

There is something wrong with the setup for your csv file, so I replaced it with sample blocks. Suggest you leave these in place until you fix everything else

Also you had an uncalled procedure called "start", so I put the setting of the variable nr in the initialize event
pChapter was set up wrong you needed global heading set instead of resetting global page_headings (ABG and Taifun already told you about this!)
To make pages 2 & 4 show the notifier i used the remainder trick, but this is possibly not scalable unless all your new chapter pages will have an even and regular divisor

So hopefully you can see where all your errors lay and you can find fixes for them. recommend you do one at a time, then test until your are sure it is fixed, then move onto the next one. Debugging multiple errors is difficult and time consuming.

Let us know how you get on ;)

-- 
Ok. It works very well as you said.
Thank you so much for your support and help.
What about if I want to read notification from file. Can you please tell me how can I make it works.

-- 
See blocks and attached aia. I created the csv using google sheets, and although they are not used, started with headers for each column

See the output in the message block for the csv

Not sure why your csv didn't want to work.



-- 
FWIW, just tested your csv file and it is working now ;)

--
Thank you so much Tim Carter. It works only first 2 chapter on the same pages but after I continue go next pages, the notification come at wrong pages. Can you please tell what is wrong that I did.


-- 
The remainder blocks test for an even number only, that is why they called the notifier on 2,4,6 and 8.

You will have to devise a test that works for all your page numbers.

One way would be to create another list of the "chapter" page numbers only, then
test the Page_No.text with the "is in list? thing/list" block

So from my previous working example:
There are other ways to do this.

Let us hope we are close to the finish now :)

--
Every things is going fine in emulator. But when I make compiling, there is an error. When I removed the global Page_List, there is no error when making compile. So, I decided to get Page_List from csv file. but it doesn't work at all.

Try making the lists using a procedure and Screen.initialize

Also you have two warnings, you will need to get rid of those.


-- 
Well done. Thank you so much. It works very well. I really appreciate of your kindness and helping people.

--

댓글 없음:

댓글 쓰기