B4A Library ICOSWorldForecast 3.50

Laurent95

Active Member
Licensed User
Longtime User
Hi Laurent, first at all I'm sorry I forgot to give U back the translation, second I'm fixing all library and specially this one. Also the Premium I'm fixing this issue thank you to remember me the issue.

No worries Giuseppe, we are all busy sometime, me too.
That sounds interesting if you can fix that.
But take your time, already you haven't computer

Best regards Giuseppe, and hold on.
 

lonleystar

Well-Known Member
Licensed User
Longtime User
Hi Laurent and all, I found the issue and fixed it (I ope)
i used my geo username in the library that's why we got the issue below.

the hourly limit of 2000 credits for lonleystar has been exceeded.
Please throttle your requests or use the commercial service.
this was the issue.

Anyway
I add:

SearchCity

B4X:
Sub Globals
    Dim ed0 As EditText
    Dim Search As ICOSForecastGetList
    Dim panel1 As Panel
End Sub

Sub b1_click
    Dim s As String
    Search.Initialize("Search")


    If ed0.Text.Length > 0 Then
        Try
          s=Search.SearchCity(ed0.Text,"ICOSWorld Forecast Demo v3.00",True)
            If s.Length > 0 Then
          a.CityName=s
          StartActivity(Forecast)
          End If
        Catch
          ToastMessageShow(" Probably server error!! ",True)
        End Try
    End If
End Sub
GeoUserName = Your User Name.

ho to get own username.

http://www.geonames.org/ click on login and create an account. Got the username give it to GeoUserName = Your User Name


or

B4X:
Try

  lab1.text="SunRise / Set : "& _
  forecast.Sunrise&" / "& _
  forecast.Sunset
 
  lab2.text="GMT: - DST: - TZID: "& _
  forecast.GmtOffset&" - "& _
  forecast.DstOffset&" - "& _
  forecast.TimeZoneID

Catch

  lab1.text="SunRise / Set :  N/A"
  lab2.text="GMT: - DST: - TZID: N/A"

End Try



or don't use the commons below till i finde something else.

Sunrise,Sunset,GmtOffset,DstOffset,TimeZoneID



P.S
I use the code above.

any bug please report to me.


 
Last edited:

Laurent95

Active Member
Licensed User
Longtime User

Hi Giuseppe,

Wowwww, you too you're victim of your success
Emmmm, hope that it's not my widget who do that, sorry if it's

Tell me please if we fix the account with our own geo username, could we have the return of code error from the library, or you're not ready for that yet ?
I ask because i fear i have the same issue, and the users make me sometime.
Thanks for your response.

And congrats for this quick update, who seems working fine.

Best regards, Laurent.
 

Laurent95

Active Member
Licensed User
Longtime User
Hi Laurent, for me it's not a problem, to avoid this issue I think it's better to have your own username.

You've to think the hourly limit is 2000 credits.

I think i don't make me enough understandable, i mean is it possible that we could have soon the error codes returned by the library for manage errors.
Because it's possible we reach also the limit of 2.000 with our application.
If we have at least the latest error returned we can test it and do something.

And in more with my widget i reach also the limit of the World Weather Online website.

I know it's not an easy thing to do but that would be very useful.
Thank you.
 
Last edited:

Laurent95

Active Member
Licensed User
Longtime User
Hi Laurent, for me it's not a problem, to avoid this issue I think it's better to have your own username.

You've to think the hourly limit is 2000 credits.

Hi Giuseppe,

It seems i have again a problem with the forecast data.
I have try to do a new account on the WorldWeatherOnline website, for be sure that the limit isn't happened.
Also i use a new account on the Geonames API website and i have always the same error code.
The error code is about the size or area see below :
B4X:
This is the part of the code, like the example does.
    Try
       Log("This day Full5DayName of library is : " & Main.a.Full5DayName(1) & CRLF & _
         "this day date is : " & Main.a.FCDate(0))    '<- i get the first error here because of the index 1 of full5dayname, the index 0 work.
       l1.Text=Main.a.Full5DayName(1)&CRLF&Main.a.FCDate(1)
       l3.Text=Main.a.Full5DayName(2)&CRLF&Main.a.FCDate(2)
       l5.Text=Main.a.Full5DayName(3)&CRLF&Main.a.FCDate(3)
       l7.Text=Main.a.Full5DayName(4)&CRLF&Main.a.FCDate(4)
       Log("Library give the Full7DayName normally")
     Catch
       'That's a little "Sub" that i have wrote when the forecast data don't support correctly the 7 days.
       ' it wouldn't needed now but i let the code like that.
       myFull5DayName(Main.a.FCDate(0))
       Log("WeatherDays lenght is " & WeatherDays.Length)
       Log("WeatherDays " & WeatherDays(0) & _
               " " & WeatherDays(1) & _
               " " & WeatherDays(2) & _
               " " & WeatherDays(3) & _
               " " & WeatherDays(4))
       ' Sorry I don't logged the error here, but at last there are 3.
       Log("This day date is : " & Main.a.FCDate(0))
       Try
         'And that the second error i get
         l1.Text=WeatherDays(1)&CRLF&Main.a.FCDate(1)   '<- the index 1 give the second error.
         l3.Text=WeatherDays(2)&CRLF&Main.a.FCDate(2)
         l5.Text=WeatherDays(3)&CRLF&Main.a.FCDate(3)
         l7.Text=WeatherDays(4)&CRLF&Main.a.FCDate(4)
       Catch
         ' The first error logged
         Log("The latest error is : " & LastException.Message)
       End Try
     End Try
   
     Try
       l2.Text=Main.a.FCTempMaxCelsius(1)&"° / "&Main.a.FCTempMinCelsius(1)&"°"  '<- the index 1 give the third error.
       l4.Text=Main.a.FCTempMaxCelsius(2)&"° / "&Main.a.FCTempMinCelsius(2)&"°"
       l6.Text=Main.a.FCTempMaxCelsius(3)&"° / "&Main.a.FCTempMinCelsius(3)&"°"
       l8.Text=Main.a.FCTempMaxCelsius(4)&"° / "&Main.a.FCTempMinCelsius(4)&"°"
       l10.Text=Main.a.FCTempMaxCelsius(5)&"° / "&Main.a.FCTempMinCelsius(5)&"°"
       l12.Text=Main.a.FCTempMaxCelsius(6)&"° / "&Main.a.FCTempMinCelsius(6)&"°"
     Catch
        ' The second error logged
     Log("The latest error is : " & LastException.Message)
     End Try

And the Log :
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (forecast) Create, isFirst = true **
(Forecast, 54) FullScreen or IncludeTitle properties in layout file do not match the activity attributes settings. (warning #1004)
This day Full5DayName of library is : Tuesday
this day date is : May 26
WeatherDays lenght is 5
WeatherDays Monday Tuesday Wednesday Thursday Friday
This day date is : May 26
The latest error is : java.lang.IndexOutOfBoundsException: Invalid index 1, size is 1
The latest error is : java.lang.IndexOutOfBoundsException: Invalid index 1, size is 1
** Activity (forecast) Resume **

An idea for why that happens ?
Thank you.

Regards, Laurent.
 

lonleystar

Well-Known Member
Licensed User
Longtime User
Hi Laurent, the problem is not world weather online is the (api.geoname.org), but i got the solution just testing before to update to the forum till tomorrow will be updated.


P.S.
the premium version depend on from free version and if it is not 100% functionality i cant post also the premium.
 

lonleystar

Well-Known Member
Licensed User
Longtime User
Hi Laurent and All, ICOSWorldForecastFree is update to 3.10 what's new:

fix the issue from Geo provider fix issue when Developer is Over Rate from World Weather Online.

Add:

RequestConnectServer Returns an error from the url page
RequestConnectServer2 Returns an error produced by the server


If You have more than one Apikey, below first tip.

B4X:
   Dim request As Int
   Dim city As String = "Melbourne"
   If a.isWiFiConnected = True Then

    request = a.RequestConnectServer2(city)

    If request > 0 Then 

    a.apiKey="XXXXXXXXXXXXXXXXXXXXXX"  - alternative key

    End If

    a.CityName = city

    StartActivity(Forecast)

   End If

End If

second tip:

B4X:
   Dim request As Int
   Dim city As String = "Melbourne"
   If a.isWiFiConnected = True Then

    request = a.RequestConnectServer(city)

    If request = 0 Then 

    a.CityName = city

    StartActivity(Forecast)

    Else

    ToastMessageShow(a.GetResponseCode(request),True)

    return

    End If

   End If
 

Laurent95

Active Member
Licensed User
Longtime User

Hi Giuseppe,

I have tried it today, it's ok the function, the both, work fine, i haven't seen already an error today, it's maybe earlier for a lot of my customers lollll.
But now we have a small problem, all the forecast data don't work they return an error, the size of index is only 1.
If you can see that, for i could do the update of my program, thank you very much.

Best regards, Laurent.
 

lonleystar

Well-Known Member
Licensed User
Longtime User
Hi Laurent, I use this way to get the right index.



B4X:
Sub Process_Globals
   Dim index As Int
End Sub



Sub img0_Click
   index = 0
   StartActivity(NextDay)
End Sub

Sub img1_Click
   index = 1
   StartActivity(NextDay)
End Sub

Sub img2_Click
   index = 2
   StartActivity(NextDay)
End Sub

Sub img3_Click
   index = 3
   StartActivity(NextDay)
End Sub

Sub img4_Click
   index = 4
   StartActivity(NextDay)
End Sub


P.S

If I understood wrong please correct me with an example.
 

Laurent95

Active Member
Licensed User
Longtime User

Sorry Giuseppe, i don't well explain myself, it's when i try to show the forecast data.
And also the library don't find the icons now, even if i have all in good place

It's better with an example see the attached zip and below the errors in the log :

LogCat connected to: 192.168.56.101:5555
--------- beginning of /dev/log/main

--------- beginning of /dev/log/system
.../...
** Activity (forecast) Create, isFirst = true **
The latest error is : java.io.FileNotFoundException: weathericon/wsymbol_0008_clear_sky_night.png
The latest error is : java.lang.IndexOutOfBoundsException: Invalid index 1, size is 1
The latest error is : java.lang.IndexOutOfBoundsException: Invalid index 1, size is 1
The latest error is : java.lang.IndexOutOfBoundsException: Invalid index 1, size is 1
** Activity (forecast) Resume **
** Activity (forecast) Pause, UserClosed = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
 

Attachments

  • ICOSWorldForecastDemov3.1lib.zip
    33.1 KB · Views: 217

Laurent95

Active Member
Licensed User
Longtime User
Hi Laurent, where are the resources --> (AResource1.GetApplicationString("Code"&CCCode))

Sorry, but no worries it's not related with the errors, the errors is on the line 105 and those who follow.
I only use CCCode in resource for separating clear/sunny and some other parts who're not related . Below the good file of resource.

For the icons it seems that is the virutal device who don't find it in rapid debug mode in the legacy debug mode the icon appears. But i have always the error with the forecast data, B4A continue to say me the index is only 1. Indeed if i use the index 0 it's ok but each time i try the forecast and not the current day i have an error.

If you want see better what's happen, you must comment all lines "Try, Catch, Log(xxxx, LastException.Message) and End Try" in the code and you can see B4A's errors in the log with the lines.

I must use this way because on my virtual device it closes the program when an error appears in the library. Then i can't debug or see what happen.
I can't loose my time for know why it does that in this moment i will see that later.

Thank you for try to see what happen Giuseppe, that's nice from you.

Regards.
 

Attachments

  • strings.zip
    957 bytes · Views: 193
Last edited:

Laurent95

Active Member
Licensed User
Longtime User
If Erel see this, can he confirm us that it's possible to test a program who use something in a sub folder of Assets directory in the rapid debug mode ?
Thanks for that, otherwise i will try more later, but that sounds weird.

Regards.
 

lonleystar

Well-Known Member
Licensed User
Longtime User
Hi Laurent, i try to understand the code u send to me.

1) all strings return null
B4X:
Dim CCCode As Int
Dim tmpDescr As String

CCCode =  Main.a.CCWeatherCode --> this return a string not int

tmpDescr = AResource1.GetApplicationString("Code"&CCCode) --> return null

tmpDescr = Main.a.CCWeatherCode -->  return the Weather code

end below i get error too.

'If tmpDescr.Contains("/") Then
     '   Dim tmpHours As Int
     '   Dim tmpStrHours1, tmpStrHours2 As String
     '   tmpStrHours1 = Main.a.CurrentTime
     '   tmpStrHours2 = tmpStrHours1.SubString2(0,tmpStrHours1.IndexOf("."))
     '   tmpHours = tmpStrHours2
     '   If tmpHours < 7 OR tmpHours > 21 Then
     '     lb4.Text=tmpDescr.SubString2(0,tmpDescr.IndexOf("/"))
     '   Else
     '     lb4.Text=tmpDescr.SubString(tmpDescr.IndexOf("/")+1)
     '   End If
     'Else
     '   lb4.Text=tmpDescr
     'End If

in sub loadsecondare as well

Dim CCCode As Int
Dim tmpDescr As String
CCCode = Main.a.FCWeatherCode(index) --> return null


all commands return a string


can u send your email so i'll send to u my demo project already compiled
 

Laurent95

Active Member
Licensed User
Longtime User


Hi Giuseppe,

Ok i try to respond and make you understanding the example i do, my comments are like commented lines in "CODE" parts and in blue in the quoted text above.
Generally i treat the things like a string because with the library for the resources it's usually stocked like string.

You can send me an email on lolizprod@gmail.com, i think it's better you send me your example, because this one is extract from my widget.
It's why it content some code different like the example usually attached to your library.

Thank you very much for your interest and the help .

Best regards, Laurent.
 
Last edited:

Laurent95

Active Member
Licensed User
Longtime User
Hi Laurent, I sent to U an Email with my demo attached.

For Your demo now i get only index error and FCIcon(1) 2 3 4 does not display nothing i really dont understand why.

Hi Giuseppe,

Thank you for all, i have respond you by email.

As i told you in the email i think it's because i still on B4A 3.5, i don't see anything other possible.
Edit : Capped, we haven't the forecast data in my example because i don't initialize the "ICOSWetaher.NumOfDays=5", grrrrrrrr .
Sorry for this mistake Giuseppe, forgive me i will bang my head many time for that. I keep in mind the old version where we don't need to initialize this.


A good indication, in rapid debug the virtual device continue to don't find the sub folder of the asset directory.
I will ask Erel for this two things when i have a bit time to do it.


Thank you for your help Giuseppe, you're always also cool
And sorry for the part of your time that i have taken

Regards, Laurent.
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…