Skip to first unread message

Deen

unread,
Jun 17, 2015, 5:31:51 AM6/17/15
to mitappinv...@googlegroups.com
Hi All,

I've just started with App Inventor 2 over the weekend to get going with a prototype for an App - currently I'm stuck with three issues:

1. Converting a date from the Gregorian to Lunar (Islamic).
2. Using an iFrame/Web Component to read data off another website (I have the embed code generated for this) and display within my App.
3. Displaying the time components: hour, minute and second as two digit figures.

I'm sure I'll come across more obstacles given I'm a newbie but I do have some level of programming experience whereby (hopefully) I won't need to be entirely spoon-fed!

#1 Date conversion - I've read online about using Joda-Time API and also found another (downloadable) API here but I'm not really sure which one to use and how exactly to integrate the API to work on my App.

#2 iFrame - I've got a website that can generate an embed code but I don't know the best way to implement this in AI2 to just show the component on the web viewer instead of the entire website.

#3 Show Time - I've got my App to show the time instance and I've got it working (hooray!) but I've noticed that when the current time is 12:03:05, it appears as 12:3:5. How can I get the timer to display the hour, minute and seconds as two digits?

I'm not even sure if #1 & #2 above are entirely possible, however would like to pick your brains about the best way to implement this and I'm open to new suggestions as well.

Many thanks in advance!

Cheers,
Deen

SteveJG

unread,
Jun 17, 2015, 8:19:10 AM6/17/15
to mitappinv...@googlegroups.com
1 - App Inventor can work with some API's
2 -  All you can show in the WebViewer is the entire web page.   You can use the Web component to download information from a Web page.
3 -   Use a join block to add a leading zero.   In pseudo code.   If length of the hour is 1 then add the zero, if not then don't

Have you read the Inventor's Guide mentioned in the resources below?   If you are coming from a Windows environment, much of what happens with AI is very different.: To get more information you could  search in the forum using the Search for topics box to the right of the colorful google at the top of this page  with terms like     API   or WebViewer and find many interesting discussions.  I believe all three of you questions have been answered many times.  (well not the Lunar API)

Here are some resources to help you learn to use the AI2 tools  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  .

Does this help you program Deen?    Please continue to ask questions here however if you read the information above, you will not have to wait for answers.

Just try some blocks and have fun.

Regards,
Steve

Taifun

unread,
Jun 17, 2015, 9:36:47 AM6/17/15
to mitappinv...@googlegroups.com
1) you will need a RESTful API to be able to use the web component, see an example here 
Taifun

Trying to push the limits of App Inventor! Snippets and Tutorials from Pura Vida Apps by Taifun.         

Deen

unread,
Jun 17, 2015, 11:18:35 AM6/17/15
to mitappinv...@googlegroups.com
Hi Taifun,

I tried your Leading Zero suggestion, however I can't seem to fit it into a clock/time scenario. The zero seems to be adding but it breaks my timer and the clock stops working...I have attached a screenshot of my blocks editor.

I will try your API tutorial as well.

thanks! 
LeadingZero_blocks.png

Deen

unread,
Jun 17, 2015, 11:22:56 AM6/17/15
to mitappinv...@googlegroups.com
I just spotted a mistake of mine where I have assigned the 'global' variable within the LeadingZero procedure - once I changed this to to the correct inputs my clock started working again but in the result, the second value still shows as a single digit without a leading zero..

Taifun

unread,
Jun 17, 2015, 11:26:11 AM6/17/15
to mitappinv...@googlegroups.com
use Do it to debug your blocks and provide a screenshot incl. Do it result
why do you calculate "seconds + 1"?
Taifun

Deen

unread,
Jun 17, 2015, 11:39:44 AM6/17/15
to mitappinv...@googlegroups.com
Sorry, what did you mean by:

use Do it to debug your blocks and provide a screenshot incl. Do it result

I use Clock.Second instance + 1 to display increasing seconds on the app - is there an alternative way to do this?

Deen

unread,
Jun 17, 2015, 11:44:28 AM6/17/15
to mitappinv...@googlegroups.com
I just removed the Second + 1 and it works okay!! It didn't work at the start - maybe I didn't test it correctly...

Taifun

unread,
Jun 17, 2015, 12:21:13 PM6/17/15
to mitappinv...@googlegroups.com
use Do it to debug your blocks and provide a screenshot incl. Do it result

Deen

unread,
Jun 17, 2015, 8:18:27 PM6/17/15
to mitappinv...@googlegroups.com
I've now got the leading zero working so my time format is successfully showing HH:MM:SS - attached my blocks view.

@SteveJG - some of the links you posted up there were useful!

Next - figure out how to use the API!

Thanks both
LeadingZero_Success.png
Message has been deleted

Deen

unread,
Jun 17, 2015, 11:13:14 PM6/17/15
to mitappinv...@googlegroups.com
I've managed to resolve points #1 and #3 above - both seem to be working okay! I'll take a look at #2 later on tomorrow.

*Edit* - In case someone else does come across this thread, I've found a Gregorian to Islamic Lunar date converter API - http://www.moonsighting.org.uk/scripts/hijri.js?return=json&date=2015-06-18
which returns the result: {"gregorian":["Thursday","18th","June","2015"],"islamic":["Khamis","1st","Ramadan","1436"]}that can be parsed into a web component.

Thanks for your help so far!

Cheers.
Deen
Reply all
Reply to author
Forward
0 new messages