Weather iOS app

Want to talk about something that isn't covered by another category?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

catalinanesia
Posts: 83
Joined: Sun Feb 16, 2014 10:08 pm

Weather iOS app

Post by catalinanesia » Mon May 18, 2015 1:03 am

Hi everyone,
I am going deeper with LiveCode learning so I decided to make a weather app.
Is there any Weather app done in LiveCode? Anyone have experience in doing one,
any tips and tricks or some published code ...
I will use the API from http://openweathermap.org/api
When time will be and it will I will post for help under the appropriate forum section.
Thanks! everyone, this forum is the best resource.

Regards,
Catalin Anesia
PS. Is there a way or a trick to be able to work on LiveCode from the iPAD? any other tablet?

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Weather iOS app

Post by jacque » Mon May 18, 2015 9:57 pm

The LC IDE only works on desktop machines. It would need to be completely rewritten to work on single-window mobile devices.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

catalinanesia
Posts: 83
Joined: Sun Feb 16, 2014 10:08 pm

Re: Weather iOS app

Post by catalinanesia » Tue May 19, 2015 3:09 pm

Hi Jacqueline,
I hoped maybe someone had a trick or something, one day hopefully the LC will be
ported on tablet, till then it still does the job as it is now.

Merci,
Catalin

catalinanesia
Posts: 83
Joined: Sun Feb 16, 2014 10:08 pm

Re: Weather iOS app

Post by catalinanesia » Tue May 19, 2015 3:35 pm

Tough design decision:
After 1 day (uau it is fast) of app mockup in LiveCode i have a working skeleton to
keep me going on development but I hit a dead end, so here it is:
1) I have a list of City names which correspond to a unique CODE and the API website
say it is better to use CODE not City names (will be quicker). How should I approach the
link between City and the corresponding CODE ? Where do I save or keep the City CODE's *.txt file?
should I make a big text field on a card and dump the CODE's there? what a pro in LC will do ? and for the
moment I target only iOS. (at this time I have a text field where you type City name)
2) I have envisioned the CITY list for the user to be designed as the Contact apps on today's phones
where you have the Alphabet letters on the side (vertical sorted) and when you touch one the big
address book will scroll to the first "word" starting with that letter and then you scroll down ...
Probably this is involving the very beast (tamed by some of you) of DataGrid in LiveCode ?
also probably I can avoid the DG by using Grouped fields or labels? other options ?

Thanks to set me on the right path ...

I am ok with basics of LiveCode concept but DG are a bit scarier, never dealt with them,
I read the forum daily (it is my news paper) so I know a lot of my questions are already answered somewhere.
Catalin Anesia

PS. I will post specific code questions under the appropriate beginner section ...
If this post should be moved please do so.

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Weather iOS app

Post by Dixie » Tue May 19, 2015 4:30 pm

The easiest API for weather I have come across is from forecast.io

catalinanesia
Posts: 83
Joined: Sun Feb 16, 2014 10:08 pm

Re: Weather iOS app

Post by catalinanesia » Tue May 19, 2015 5:26 pm

Thanks! Dixie,
I looked into it but the down side I see is that I can not call the API with City name,
or maybe I did not found the way ... (latitude,longitude is required) how do I get that for
the City that User wants to select? I have no idea how to use Location service :(

Did you worked on Weather apps? any tips? ...

Regards,
Catalin

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Weather iOS app

Post by Klaus » Tue May 19, 2015 6:03 pm

Hi Catalin,

1. you can use a custom property to store your (text) file.
But in your case you better use a field and also use that field to let the user choose a city.

Make a TAB delimited text file if possible:
Name of City TAB code for that city
Name of City2 TAB code for that city2
...
And import this into a list field!
Set the TABSTOPS of that field so the user will not see the CODES.

2.
a. Then create your alphabet buttons, and label them A, B, C etc...
b. Group all these buttons
c. Add this script to the group:

Code: Select all

on mouseup

   ## What button did the user click:
   put the label of the target into tFirstChar

   ## Check if a City with that first character is in the list
   put lineOffset(CR & tFirstChar, field "citylist") into tOffSet 
   ## Without the trick with "CR & tFirstChar" lineoffset will not look for the first character of the lines!

   if tOffSet = 0 then
      beep 
      exit mouseup
   end if

   ## Success! Now scroll the first line starting with that character into view:
   set the scroll of field "citylist" to round(tOffSet * the effective textHeight of field "citylist")
end mouseup
d. Then you can easily extract the corresponding CODE to a selected city:
...
set itemdel to TAB
put item 2 of the selectedtext of fld "citylist" into tCode
...

Best

Klaus

catalinanesia
Posts: 83
Joined: Sun Feb 16, 2014 10:08 pm

Re: Weather iOS app

Post by catalinanesia » Tue May 19, 2015 6:06 pm

Dear Klaus,
You just made me a happier LiveCode user ...

Thanks!

Newbie4
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 332
Joined: Sun Apr 15, 2012 1:17 am
Contact:

Re: Weather iOS app

Post by Newbie4 » Tue May 19, 2015 6:47 pm

There is some background information on different data formats, apps, mashups and even a weather example at https://sites.google.com/a/pgcps.org/li ... rogramming (sections 3.1 and 3.2)

It is short reading

You can get the latitude,longitude of your city using a Geocoding API such as Google Map's. (Do a Google search on "geocoding api"
Cyril Pruszko
https://sites.google.com/a/pgcps.org/livecode/
https://sites.google.com/a/setonhs.org/app-and-game-workshop/home
https://learntolivecode.com/

catalinanesia
Posts: 83
Joined: Sun Feb 16, 2014 10:08 pm

Re: Weather iOS app

Post by catalinanesia » Tue May 19, 2015 7:33 pm

Thanks! Newbie4,

I started all this (LiveCode) due to your well know web page ...
I read your mashup link a few times already and did your weather example so
I am building on top of that knowledge + some crazy design ideas ;) and dev.

Regards!

Newbie4
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 332
Joined: Sun Apr 15, 2012 1:17 am
Contact:

Re: Weather iOS app

Post by Newbie4 » Tue May 19, 2015 7:43 pm

Thanks, you are doing a great job. You are getting to be an expert in your own right by the quality of your questions.

Please post some screen shots of your app when it is done. Thanks
Cyril Pruszko
https://sites.google.com/a/pgcps.org/livecode/
https://sites.google.com/a/setonhs.org/app-and-game-workshop/home
https://learntolivecode.com/

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Weather iOS app

Post by Klaus » Tue May 19, 2015 8:39 pm

Hi Catalina,
catalinanesia wrote:Dear Klaus,
You just made me a happier LiveCode user ...

Thanks!
You're welcome! :D

To add some icing on the cake you could add this as that last line in the groups "mouseup" handler:

Code: Select all

   ...
    set the hilitedlines of fld "citylist" to tOffSet
end mouseup
Looks quite "pro" and will prevent eventual suprise when the user now uses the arrow keys to navigate throught the list field!
Know what I mean? 8)


Best

Klaus

catalinanesia
Posts: 83
Joined: Sun Feb 16, 2014 10:08 pm

Re: Weather iOS app

Post by catalinanesia » Mon May 25, 2015 5:07 pm

Dear Klaus,
I have been testing/playing/shuffling your code but unfortunately I have not been able to make it work ...
It will always go on top at the first line ... your instructions were pretty straight forward so I think is
a little problem in to the CODE.
I have a "Scrolling List Field" named citylist (Contains city names and codes TAB delimited), a group of buttons (ABCDEF) and your code in the group script ...
If you have a chance will you review the code and give me a hint ?

Thanks!
Catalin

catalinanesia
Posts: 83
Joined: Sun Feb 16, 2014 10:08 pm

Re: Weather iOS app

Post by catalinanesia » Mon May 25, 2015 5:30 pm

Wowww Klaus,
Sorry for me rushing into conclusions ...
It works perfect if I give a name on the buttons "Label" under properties ...
I'm embarrassed, please accept my apologies regarding your perfect CODE.
Enjoy!
Catalin

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Weather iOS app

Post by Klaus » Mon May 25, 2015 5:34 pm

Hi Catalin,

just tested my script and it worked as exspected!?
I slightly modiefied the "hilite" part to take the additional CR into account:

Code: Select all

on mouseup
   
   ## What button did the user click:
   put the label of the target into tFirstChar
   
   ## Check if a City with that first character is in the list
   put lineOffset(CR & tFirstChar, field "citylist") into tOffSet 
   ## Without the trick with "CR & tFirstChar" lineoffset will not look for the first character of the lines!
   
   if tOffSet = 0 then
      beep 
      exit mouseup
   end if
   
   ## Success! Now scroll the first line starting with that character into view:
   set the scroll of field "citylist" to round(tOffSet * the effective textHeight of field "citylist")
   
   if tOffset > 1 then
      add 1 to tOffset
   end if
   set the hilitedlines of fld "citylist" to tOffSet
end mouseup
Best

Klaus

Post Reply