Pocket Weather

Discussion in 'Open Source Projects' started by digitaldon37, Nov 12, 2008.

  1. digitaldon37

    digitaldon37 Active Member Licensed User

    Pocket Forecast (formerly Pocket Weather)

    Current Version: 1.2.5

    Description: Pocket Forecast is a weather application that supports mutliple locations, multiple languages, QVGA AND VGA display, cached AND user defined updates, customized theme, AND is open source written in Basic4PPC.

    Source code and CAB installer at: pocket_forecast [CampusBBS Wiki]

    Last update: 6/4/09
     

    Attached Files:

    Last edited: Jun 4, 2009
  2. digitaldon37

    digitaldon37 Active Member Licensed User

    FilesEx error

    I am getting an error while reading a file's attributes with the FilesEx library - but only when I run a compiled version. I don't get the error from within the IDE. Any ideas?

    The GetYahooRSS code (with some msgbox's to display steps):
    Code:
    If FileExist(AppPath & "\" & CurrentLocationCode & ".cache") = True Then
          
    ' Requires FilesEx library - agraham
          Msgbox("creating reference to FilesEx library...")
          filb.New1
          
    Msgbox("getting file attributes via FilesEx library...")
          fileInfo()=filb.FileInfo(AppPath & 
    "\" & CurrentLocationCode & ".cache")
          
    ' Msgbox(filb.Dllversion)
          Msgbox("splitting file into into array...")
          arrDateTime()=StrSplit(fileInfo(
    2))
          
    Msgbox("comparing file datestamp with current date...")
    It errors at the "fileInfo()=filb.FileInfo" line.

    UPDATE: Never mind. I was using version 1.2 of the FilesEx library and the current one is 1.3 - the latest version fixes this.
     
    Last edited: Nov 12, 2008
  3. digitaldon37

    digitaldon37 Active Member Licensed User

    Pocket Weather v.16

    With version .16 I have a usable weather application that supports up to 5 locations. I am currently working on the settings editor (accessible by clicking on the tiny weather icon next to the "Last update" status on the main page) but I have enough working that multiple locations can be loaded from the INI file and the default location (ie the one that is in view) can be changed.

    Changes are not saved when the program exits - that is the code I am currently working on. Any feedback is welcome - I took the comments made on other weather applications and used those as functional requirements.

    Update: Location & Settings completed, uploading v.17 on 1st post
     

    Attached Files:

    Last edited: Nov 14, 2008
  4. digitaldon37

    digitaldon37 Active Member Licensed User

    Need help with bug (form control values "lost")

    I have a bug that I haven't been able to track down yet. When clicking on the "Close" button on the configuration screen, the application updates global variables for location id, theme, timeouts, etc and then updates the INI file.

    The problem is that (3) variables (for theme, http, refresh) are updated with no values. I am using the form controls values to update the global variables, so I am at a lost why some work and some don't.

    As a temporary solution, I added a code check to see if the form controls are empty and then update the global variable only if there is a value, but this isn't the best solution since some of those controls get updated.

    I've uploaded the latest code (v.19) on the 1st post if anyone can help.
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    Looks like a great program :sign0188:
    How can I get to the configuration page?
     
  6. digitaldon37

    digitaldon37 Active Member Licensed User

    Thanks for the feedback.

    You get to the configuration screen by pressing the tiny weather icon near the status message on the main page.
     
  7. digitaldon37

    digitaldon37 Active Member Licensed User

    version .20

    (cross posted at xda-developers.com)

    Version .20 has been uploaded to the main post.

    1. Portrait/Landscape mode (repaint screen when switching between two)
    2. Finger-swipe down opens configuration screen (the tiny weather icon is still there until this is fully tested)
    3. Button and misc. messaging changes (per suggestions)
    4. Cache (if available) is loaded on application start-up - updates can be done manually or configured every X minutes
    5. Location cache are deleted if the location/zip code is deleted
    6. RetrieveRSS functions (remote/local) rewritten

    Next to do: apply theme settings (theme.ini)
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    Weather.jpg should be located under gfx folder instead of the root folder.
    Code:
    ' application image buttons
        If FileExist(AppPath & "\gfx\weather.jpg"Then
            imgHotKey.Image=AppPath & 
    "\gfx\weather.jpg"
        
    End If
     
  9. Erel

    Erel Administrator Staff Member Licensed User

    You are only updating the three variables when the user presses on rbtnSettings.
    If the user just opens the settings page and closes it these three variables will not be updated.
    Here is a possible solution:
    Code:
    Sub editLocations
        rbtnLocations.Checked=
    True
        pnlLocations.Enabled=
    True
        pnlLocations.Visible=
    True
        pnlSettings.Enabled=
    False
        pnlSettings.Visible=
    False
        
        lblDefault.Visible=
    True
        lblLocationDescription.Visible=
    True
        lblDelete.Visible=
    True
        
    Select CurrentLocationCode
            
    Case Location(0)
                rbtnLocation1.Checked=
    True
            
    Case Location(1)
                rbtnLocation2.Checked=
    True
            
    Case Location(2)
                rbtnLocation3.Checked=
    True
            
    Case Location(3)
                rbtnLocation4.Checked=
    True
            
    Case Location(4)
                rbtnLocation5.Checked=
    True
        
    End Select
        
        form3.show
    End Sub
    Sub editSettings
        rbtnSettings.Checked=
    True
        pnlSettings.Enabled=
    True
        pnlSettings.Visible=
    True
        pnlLocations.Enabled=
    False
        pnlLocations.Visible=
    False
        lblDefault.Visible=
    False
        lblLocationDescription.Visible=
    False
        lblDelete.Visible=
    False

        
    Select ini.mainWeatherUnits
            
    Case "c"
                rbtnCelcius.Checked=
    True
            
    Case "f"
                rbtnFarenheit.Checked=
    True
        
    End Select
        form3.Show
    End Sub
    Sub updateSettings
        txtThemeSetting.Text=INI.themeDir
        txtHttpSetting.Text=INI.httpTimeout
        txtRefreshSetting.Text=INI.refreshInterval
        txtLocation1.Text=
    Location(0)
        txtlocation2.Text=
    Location(1)
        txtLocation3.Text=
    Location(2)
        txtLocation4.Text=
    Location(3)
        txtLocation5.Text=
    Location(4)
    End Sub
    Sub Form3_Show
        updateSettings
    End Sub
    If you like you can use an ImageList and add all your images to this list.
    That way the images will be merged in the executable.
     
  10. digitaldon37

    digitaldon37 Active Member Licensed User

    Thanks Erel for looking through the code and for the suggestion. I am going to make those changes and test it out.

    I didn't want to merge the images into the executable because I want to give users (of the compiled version) to be able to use different sets of weather images - part of how themes will be implemented.

    The customer service and community forums are reasons why B4PPC is such a great product!
     
  11. klaus

    klaus Expert Licensed User

    Hi digitaldon37,
    I had a look at your program, very nice and interesting.

    One suggestion would be to insert somewhere the link to
    Yahoo! Weather
    where the user can find its location(s) from all around the world.

    I tried some locations from Europe, works fine.

    In your code you should add a test if
    WeatherCurrent.code = 3200
    3200 is the unknown code, this code is sometimes given for certain locations.
    And in this case, in the Sub SetMainPage routine, line
    imgCurrent.Image=AppPath & "\themes\" & INI.themeDir & "\conditions\" & WeatherConditionImages(WeatherCurrent.code)
    generates an error.

    There does also exist a condition code 0 (tornado), you shoud add an image 0.jpg for this code.

    The images in your last version look nicer to me than those from the nws.
    Didn't you have a link for their images in your first post ?

    Best regards.

     
  12. digitaldon37

    digitaldon37 Active Member Licensed User

    Hi Klaus - thanks for the feedback and finding the bugs - I'll get those added to the next release.

    I haven't decided exactly how to let the user find their location id yet. I am thinking of added a new program form with agraham's webbrowser library and inserting the Yahoo page (there doesn't seem to be a web service available) and to capture the result.

    The original icons (before I grabbed the Yahoo icons) I think I got from here: Weathericons - Weatherstation Salo, Halikko, FI. I was going to go back and put together a post on how to change the theme and weather icons.
     
  13. klaus

    klaus Expert Licensed User

  14. klaus

    klaus Expert Licensed User

    Hi digitaldon37,

    I wanted to learn a bit more in retrieving web information, so I took your program as a first sample.

    As once suggested, I took the liberty to add a location search to your program.
    I didn't make any cosmetics.

    If you are interested in you can for shure use it.

    I post only the sbp file.

    Best regards.
     

    Attached Files:

    Last edited: Nov 17, 2008
  15. digitaldon37

    digitaldon37 Active Member Licensed User

    This is great! I will add it to the next developer release. Thanks Klaus! :)
     
  16. digitaldon37

    digitaldon37 Active Member Licensed User

    version .25

    Developer's version .25 has been uploaded to the main post. This version contains the location look-up code that Klaus generously provided.

    I am going to try to wait at least a week before adding any new enhancements. This will give me enough time to test this thoroughly. Thanks to everyone for their help and feedback.
     
  17. klaus

    klaus Expert Licensed User

    Hi digitaldon37,

    In the location search part of the program you should change one line.
    Code:
    [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]
    [SIZE=
    2][FONT=Courier New][COLOR=#0000ff]Sub [/COLOR][/FONT][/SIZE][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]cbxCountry_SelectionChanged (Index, Value)[/SIZE][/FONT]
    [/SIZE][/
    FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] txt[/SIZE][/FONT]
     
    [SIZE=
    2][FONT=Courier New]  cbxCity.Visible=[/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]True[/COLOR][/SIZE][/FONT]
    [/COLOR][/SIZE][/
    FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]  RegionI=Index[/SIZE][/FONT]
    [SIZE=
    2][FONT=Courier New]  txt=[/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"http://weather.yahoo.com/"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]&AL2.Item(Index)[/SIZE][/FONT]
    [SIZE=
    2][FONT=Courier New]  WebRequest(txt)[/FONT][/SIZE]
    [SIZE=
    2][FONT=Courier New]  BrowseSubRegional[/FONT][/SIZE]
    [/SIZE][/
    FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]  If[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] cbxCity.Count > [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=red][B]20 [/B][/COLOR][/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]AND [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]StrAt[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2](cbxCity.Item([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]),[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]) = [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]StrAt[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2](cbxCity.Item(cbxCity.Count-[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]),[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]) [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE][/FONT]
    [/COLOR][/SIZE][/
    FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]    cbxAlphabet.Visible = [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]True[/COLOR][/SIZE][/FONT]
    [/COLOR][/SIZE][/
    FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]    cbxAlphabet.SelectedIndex=[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT]
    [/COLOR][/SIZE][/
    FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]  Else[/COLOR][/SIZE][/FONT]
    [/COLOR][/SIZE][/
    FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]    cbxAlphabet.Visible = [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]False  [/COLOR][/SIZE][/FONT]
    [/COLOR][/SIZE][/
    FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]  End [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/FONT]
    [SIZE=
    2][FONT=Courier New][COLOR=#0000ff]End Sub[/COLOR][/FONT][/SIZE]
    [/COLOR][/SIZE][/
    FONT][/COLOR][/SIZE][/FONT]
    You should replace 1 by 20. Because the routine checks if the first character of the first and last city name is equal and if yes displays the alphabet combobox.
    Unfortunately for Estonia there is only 1 city list but the first and last city names begin with the same character.

    Best regards.
     
  18. digitaldon37

    digitaldon37 Active Member Licensed User

    Thanks. I made the change and am testing with some other minor tweaks.
     
  19. Filippo

    Filippo Expert Licensed User

    Hi digitaldon37,

    thank you, very good work.:sign0188:


    Ciao,
    Filippo
     

    Attached Files:

  20. JOTHA

    JOTHA Well-Known Member Licensed User

    Hi digitaldon37,

    very nice work! :sign0188:

    Do you also want to have it in other languages (German)?
     

    Attached Files:

Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice