Page 2 of 4

Re: un pequeño ejemplo ...meteo.prg

PostPosted: Tue Dec 09, 2014 6:20 pm
by Silvio.Falconi
Please Manuel,

Local aforecast:= {}
Local header_date:= I18n("Data")
Local header_day:= I18n("Giorno")
Local header_max:= I18n("Massima")
Local header_min:= I18n("Minima")
Local header_prev:= I18n("Previsione")
Local header_image:= I18n(" ")
Local oBrwForecast

DEFINE DIALOG oDlg TITLE "Risultati" SIZE 500, 550 pixel color CLR_BLACK,CLR_WHITE


aHTexto:=hVar2["forecast"]

for i=1 to len(aHTexto)



hDias:=aHTexto[i]
/*
cTexto:= "Data: " + hDias["date"] +CRLF
cTexto+= "giorno : " + hDias["day"] +CRLF
cTexto+= "Massima: " + hDias["high"] +CRLF
cTexto+= "Minima: " + hDias["low"] +CRLF
cTexto+= "Previsione:" + hDias["text"] +CRLF
cTexto+= "Codigo de imagen :" + hDias["code"] +CRLF*/

* msginfo( cTexto )

cData:= hDias["date"]
cDay:= hDias["day"]
cMax:= hDias["high"]
cMin:= hDias["low"]
cPrev:= hDias["text"]
cImage:= hDias["code"]

// "http://l.yimg.com/a/i/us/we/52/"+hDias["code"]+".gif"

AaDd(aForecast,{cData,cDay,cMax,cMin,cPrev,cImage})

next


@ 185,10 XBROWSE oBrwForecast SIZE 250,060 PIXEL OF oDlg;
DATASOURCE aForecast ;
COLUMNS 1,2,3,4,5,6 ;
HEADERS header_date,header_day,header_max,header_min,header_prev,header_image;
COLSIZES 45, 45,45,50,80,45

WITH OBJECT oBrwForecast
:nMarqueeStyle := MARQSTYLE_HIGHLROW
:lHScroll := .f.

:CreateFromCode()
END

It showed on horizontal 1 record one day instead I wish show on vertical ...mhm,.. perhaps it need a matricial math but Inot Know how make it

Re: un pequeño ejemplo ...meteo.prg

PostPosted: Tue Dec 09, 2014 6:32 pm
by Silvio.Falconi
after run ok... now gime me an error when load forecast but it load the array the same ... I not understood why

Re: un pequeño ejemplo ...meteo.prg

PostPosted: Tue Dec 09, 2014 7:16 pm
by mastintin
Silvio.Falconi wrote:after run ok... now gime me an error when load forecast but it load the array the same ... I not understood why

Probablemente una de las llamadas a los bmps esté fallando por falta de tiempo en la carga ( se carga antes la pantalla que se descarga el bmp ) .

Re: un pequeño ejemplo ...meteo.prg

PostPosted: Tue Dec 09, 2014 8:13 pm
by mastintin
Silvio , Nueva versión con tu propuesta :D :

Code: Select all  Expand view



// Our first DialogBox sample

#include "FiveWin.ch"
#include "ttitle.ch"

function Main()
  local obmp ,cBmp
  local oDlg, oIco ,cCity:= "Marbella"+space(20)
  local cUrl := "http://l.yimg.com/a/i/brand/purplelogo//uh/us/news-wea.gif"
  local ofont
   
   DEFINE Font ofont NAME "Verdana" SIZE 0,14
   
   DEFINE ICON oIco FILE "..\icons\fivewin.ico"

   DEFINE DIALOG oDlg TITLE "Ciudad a buscar" ;
      ICON oIco SIZE 350, 240

   @ 30,10  IMAGE oBmp FILE cBmp OF oDlg size 142,35 pixel NOBORDER
     
     obmp:lTransparent := .t.
     cargaBmp(cUrl,oBmp)
     
   //  oBmp:display()
       
   
     @ 60, 10 SAY "Introduce la ciudad a buscar :" size 100, 12 ;
                        FONT oFont pixel OF oDlg
     
     @ 70, 10 GET cCity size 120, 12 FONT oFont pixel OF oDlg

     @ 105, 85 BUTTON "&Buscar" SIZE 40, 12 OF oDlg pixel ;
              FONT oFont ;
              ACTION llamada(cCity)

     @ 105,130 BUTTON "&Salir" SIZE 40, 12 pixel OF oDlg;
               FONT oFont ;
               ACTION oDlg:End()

   ACTIVATE DIALOG oDlg CENTERED ;
    ON INIT  DlgBarTitle( oDlg, "  Servicio Metereologico","c:\fwh\bitmaps\alphaBmp\weather.bmp" ,44 )  ;
    ON PAINT DlgStatusBar(oDlg, 68,, .t. )
   
return nil

//------------------------------------------------------------------------------

Function cargaBmp(cUrl,oImage)
local cResp := loadBmp(cUrl)
local nZeroZeroClr
 if !Empty( cResp )
     // oImage:LoadFromString( cResp )
    oImage:LoadFromMemory( cResp )
    oImage:HasAlpha()
    oImage:Refresh()
 endif
Return nil

//------------------------------------------------------------------------------

//------------------------------------------------------------------------------

Function loadBmp(cUrl)
local oHttp
local cResp := nil

   Try
      oHttp := CreateObject( "winhttp.winhttprequest.5.1" )
      oHttp:Open("GET", cUrl, .f. )
      oHttp:Send()
   
      cResp := oHttp:ResponseBody()
      oHttp:WaitForResponse()  
     
   Catch
      MsgStop( "Error" )
      Return cResp
   End Try
 
Return cResp

//------------------------------------------------------------------------------




Function llamada(cCity)
local oHttp
local cResp
local cDir
local Formato :=  "json"  // "xml"  
local cUnits:= "c"

cDir := "https://query.yahooapis.com/v1/public/yql?q=select * from weather.forecast where woeid in (select woeid from geo.places(1)"
cDir:= cDir + " where text= '"+ cCity +"' ) and u='"+cUnits+"'&format=" + Formato
 
 Try
      oHttp := CreateObject("winhttp.winhttprequest.5.1")
      oHttp:Open("GET", cDir, .f. )
      oHttp:Send()
      cResp := oHttp:ResponseText()
         oHttp:WaitForResponse()  
     // memowrit("eltiempo.txt",cResp )
     // msginfo("grabado")
     // winexec( "notepad.exe eltiempo.txt" )
     
     leejson( cResp )
   Catch
      MsgStop( "Error" )
      Return cResp
   End Try


Return nil

//------------------------------------------------------------------------------

function Leejson(cResp )
local hvar
local hvar1,hvar2
local cTexto:=""
local oDlg, cBmp
local nValor
local oBmp
local ofont1,ofont2
Local oBrwForecast

local aForecast:= {}
local i
local cImage,cMin,cMax,cData,cDay
local ahTexto,hDias,cPrev
local cUrl

hb_jsondecode( cResp, @hvar )

hvar1:= hvar["query"]["results"]["channel"]

 define font ofont1 name "Arial" size 0,16 bold

 DEFINE Font ofont2 NAME "Verdana" SIZE 0,13

 DEFINE DIALOG oDlg TITLE "Resultados" SIZE 500, 550 pixel color CLR_BLACK,CLR_WHITE
 
 
    @ 10 ,80 SAY alltrim(hvar1["title"] ) OF oDlg SIZE 180, 20 ;
                        pixel Font ofont1 color CLR_BLACK,CLR_WHITE
     
     @ 25, 70 SAY "Fecha : "+ alltrim(hvar["query"]["created"])  SIZE 180, 20 OF oDlg ;
                    pixel  color CLR_BLACK,CLR_WHITE FONT ofont2
               
     hvar2:= hvar1["wind"]
     
     @ 40, 100 say alltrim("Viento") SIZE 50, 20  OF oDlg  ;
                        pixel COLOR CLR_BLACK,CLR_WHITE FONT ofont1
     @ 50, 50 say alltrim("Sensacion Termica :" )  OF oDlg ;
               pixel color CLR_BLACK,CLR_WHITE FONT ofont2
     @ 50, 130 say alltrim( hVar2["chill"]+chr(186)+" "+ hvar1["units"]["temperature"] )  OF oDlg ;
              pixel color CLR_BLACK,CLR_WHITE FONT ofont2        
             
             
     @ 60, 50 say "Direcccion " OF oDlg ;
             pixel  color CLR_BLACK,CLR_WHITE FONT ofont2
     @ 60, 130 say  hVar2["direction"]  OF oDlg ;
             pixel  color CLR_BLACK,CLR_WHITE FONT ofont2        
             
     @ 70, 50 say "Velocidad "  OF oDlg ;
                     pixel  color CLR_BLACK,CLR_WHITE FONT ofont2
     
     @ 70, 130 say  hVar2["speed"]+" "+ hvar1["units"]["speed"]  OF oDlg ;
                     pixel  color CLR_BLACK,CLR_WHITE FONT ofont2
   
         
        hvar2:= hvar1["atmosphere"]
   
   
     @ 85, 95 say "Atmosfera " OF oDlg ;
                      pixel  color CLR_BLACK,CLR_WHITE FONT ofont1
                     
     @ 100, 50 say "Humedad " OF oDlg ;
                    pixel  color CLR_BLACK,CLR_WHITE FONT ofont2
     @ 100, 130 say  hVar2["humidity"] + " %" OF oDlg ;
                    pixel  color CLR_BLACK,CLR_WHITE FONT ofont2
                                       
                   
     @ 110, 50 say "Presion Barometrica " OF oDlg ;
                        pixel   color CLR_BLACK,CLR_WHITE FONT ofont2
                       
     @ 110, 130 say hVar2["pressure"] + " "+ hvar1["units"]["pressure"] OF oDlg ;
                        pixel   color CLR_BLACK,CLR_WHITE FONT ofont2
                               
     
     nValor:= hVar2["rising"]
     
     if  nValor == "0"
         cTexto := "Estable"
     elseif nValor == "1"
         cTexto := "Subiendo"
     elseif nValor == "2"  
         cTexto := "Bajando"
     endif
       
     @ 120, 50 say "Tendencia Barometrica: "  OF oDlg ;
                        pixel color CLR_BLACK,CLR_WHITE FONT ofont2
     @ 120, 130 say cTexto OF oDlg ;
                        pixel color CLR_BLACK,CLR_WHITE FONT ofont2
   
     
      hvar2:= hvar1["astronomy"]
     
   
     
     @ 160, 30 say "Orto " + hVar2["sunrise"] OF oDlg ;
                         pixel color CLR_BLACK,CLR_WHITE FONT ofont2
                         
     @ 160, 160 say "Ocaso " + hVar2["sunset"] OF oDlg ;
                         pixel color CLR_BLACK,CLR_WHITE FONT ofont2
 
 
 
      hvar2:= hvar1["item"]
     
     
     

aHTexto:=hVar2["forecast"]

for i=1 to len(aHTexto)


hDias:=aHTexto[i]


cData:= hDias["date"]
cDay:= hDias["day"]
cMax:= hDias["high"]
cMin:= hDias["low"]
cPrev:= hDias["text"]
cUrl:= "http://l.yimg.com/a/i/us/we/52/"+hDias["code"]+".gif"

cImage:= loadBmp(cUrl)  

Aadd(aForecast,{cData,cDay,cMax,cMin,cPrev,cImage} )


next


@ 185,10 XBROWSE oBrwForecast SIZE 230,060 PIXEL OF oDlg;
DATASOURCE aForecast ;
COLUMNS 1,2,3,4,5,6 ;
HEADERS "Fecha","Dia","maxima","minima","prevision","imagen" ;
COLSIZES 45, 45,45,50,80,45

WITH OBJECT oBrwForecast
:nMarqueeStyle := MARQSTYLE_HIGHLROW
 :lHScroll := .f.


 :CreateFromCode()
 
END
   
 
         
      cTexto:=hVar2["condition"]["code"]
     
      cTexto:="http://l.yimg.com/a/i/us/we/52/"+cTexto+".gif"    
       
     @ 10,12  IMAGE oBmp FILE cBmp OF oDlg size 32,32 pixel NOBORDER
         
      cargaBmp(cTexto,oBmp)
     
         
    @ 260, 100 BUTTON "&Ok" SIZE 40, 12  OF oDlg pixel ;
      ACTION odlg:end() FONT oFont2
   
 ACTIVATE DIALOG oDlg CENTERED on paint  DlgStatusBar(oDlg, 68,, .t. )
 
  ofont1:end()
  ofont2:end()  

 return nil

//------------------------------------------------------------------------------







//------------------------------------------------------------------------------

Function DlgStatusBar(oDlg, nHeight, nCorrec , lColor )
Local nDlgHeight := oDlg:nHeight
Local aColor     := { { 0.40, nRGB( 200, 200, 200 ), nRGB( 184, 184, 184 ) },;
                    { 0.60, nRGB( 184, 184, 184 ), nRGB( 150, 150, 150 ) } }

DEFAULT nHeight  := 72
DEFAULT nCorrec  := 0
DEFAULT lColor   := .F.

nDlgHeight:= nDlgHeight+ncorrec
IF lColor
   GradienTfill(oDlg:hDC,nDlgHeight-( nHeight-2 ),0,nDlgHeight-20,oDlg:nWidth, aColor ,.t.)
   WndBoxIn( oDlg:hDc,nDlgHeight-( nHeight-1 ),0,nDlgHeight-( nHeight ),oDlg:nWidth )
ELSE
   WndBoxIn( oDlg:hDc,nDlgHeight -( nHeight-1 ),4,nDlgHeight-( nHeight ),oDlg:nWidth - 10 )
endif

Return Nil

//------------------------------------------------------------------------------

FUNCTION DlgBarTitle( oWnd, cTitle, cBmp ,nHeight )
   LOCAL oFont
   LOCAL oTitle
   LOCAL nColText := 180
   LOCAL nRowImg  := 0
   

   DEFAULT cTitle  := ""
   DEFAULT nHeight := 48

   IF nHeight < 48
      nColText := 60
      nRowImg  := 12
      DEFINE FONT oFont NAME "Arial" size 10, 30
   ELSE
      DEFINE FONT oFont NAME "Arial" size 12, 30
   endif

    @ -1, -1  TITLE oTitle size oWnd:nWidth+1, nHeight+1 of oWnd SHADOWSIZE 0
   
   @  nRowImg,  10  TITLEIMG  OF oTitle BITMAP cBmp  SIZE 48, 48 REFLEX ;
          TRANSPARENT
   
    @  nRowImg-2 ,  nColText TITLETEXT OF oTitle TEXT cTitle COLOR CLR_BLACK FONT oFont

    oTitle:aGrdBack := { { 1, RGB( 255, 255, 255 ), RGB( 229, 233, 238 )  } }
    oTitle:nShadowIntensity = 0
    oTitle:nShadow = 0
    oTitle:nClrLine1 := nrgb(0,0,0)
    oTitle:nClrLine2 := RGB( 229, 233, 238 )
    oWnd:oTop:= oTitle
   
     

RETURN oTitle

 

Re: un pequeño ejemplo ...meteo.prg

PostPosted: Tue Dec 09, 2014 8:33 pm
by Silvio.Falconi
Manuel,
here not load the array into xbrowse and the xbrowse is empty ...

Mesa Aquí xbrowse permanece vacío y la matriz no cobrar probablemente tal vez tenemos que cargar la imagen después y no antes. Podemos guardar el vínculo de la imagen y cuando creo la tabla xbrowse la imagen podría cobrar


I tried with
Aadd(aForecast,{cData,cDay,cMax,cMin,cPrev,cUrl} )
...
WITH OBJECT oBrwForecast:aCols[6]
:nEditType := TYPE_IMAGE
:lBmpStretch := .F.
:lBmpTransparent := .t.
:bStrImage := { || loadBmp(aForecast[6])}
:bStrData :={ || ""}
END

pero se necesita mucho tiempo para cargar la imagen

Re: un pequeño ejemplo ...meteo.prg

PostPosted: Tue Dec 09, 2014 8:38 pm
by cnavarro
Manuel, un gran aporte
Gracias

Re: un pequeño ejemplo ...meteo.prg

PostPosted: Tue Dec 09, 2014 8:43 pm
by sysctrl2
perfecto
si muestra el xbrw con los días de la semana,
gracias.

Re: un pequeño ejemplo ...meteo.prg

PostPosted: Tue Dec 09, 2014 9:07 pm
by Silvio.Falconi
sysctrl2 wrote:perfecto
si muestra el xbrw con los días de la semana,
gracias.


but here not load images

Re: un pequeño ejemplo ...meteo.prg

PostPosted: Tue Dec 09, 2014 9:26 pm
by mastintin
A veces si a veces no ... depende de la velocidad de conexión , no encuentro como solucionarlo :( .
Una soluciuon es tener descargados ya las imágenes , o grabarlas en un archivo temporal ....
Mañana lo repienso a ver si lo solucionamos
Image

Re: un pequeño ejemplo ...meteo.prg

PostPosted: Tue Dec 09, 2014 9:31 pm
by Silvio.Falconi
I found the solution !!!!!!!!!!!!!!!!!

Image


no xbrowse !!!!

the code ( to make best)

Code: Select all  Expand view



// Our first DialogBox sample

#include "FiveWin.ch"
#include "ttitle.ch"

function Main()
  local obmp ,cBmp
  local oDlg, oIco ,cCity:= "Marbella"+space(20)
  local cUrl := "http://l.yimg.com/a/i/brand/purplelogo//uh/us/news-wea.gif"
  local ofont

   DEFINE Font ofont NAME "Verdana" SIZE 0,14

   DEFINE ICON oIco FILE "..\icons\fivewin.ico"

   DEFINE DIALOG oDlg TITLE "Ciudad a buscar" ;
      ICON oIco SIZE 350, 240

   @ 30,10  IMAGE oBmp FILE cBmp OF oDlg size 142,35 pixel NOBORDER

     obmp:lTransparent := .t.
     cargaBmp(cUrl,oBmp)

   //  oBmp:display()


     @ 60, 10 SAY "Introduce la ciudad a buscar :" size 100, 12 ;
                        FONT oFont pixel OF oDlg

     @ 70, 10 GET cCity size 120, 12 FONT oFont pixel OF oDlg

     @ 105, 85 BUTTON "&Buscar" SIZE 40, 12 OF oDlg pixel ;
              FONT oFont ;
              ACTION llamada(cCity)

     @ 105,130 BUTTON "&Salir" SIZE 40, 12 pixel OF oDlg;
               FONT oFont ;
               ACTION oDlg:End()

   ACTIVATE DIALOG oDlg CENTERED ;
    ON INIT  DlgBarTitle( oDlg, "  Servicio Metereologico","c:\fwh\bitmaps\alphaBmp\weather.bmp" ,44 )  ;
    ON PAINT DlgStatusBar(oDlg, 68,, .t. )

return nil

//------------------------------------------------------------------------------

Function cargaBmp(cUrl,oImage)
local cResp := loadBmp(cUrl)
local nZeroZeroClr
 if !Empty( cResp )
     // oImage:LoadFromString( cResp )
    oImage:LoadFromMemory( cResp )
    oImage:HasAlpha()
    oImage:Refresh()
 endif
Return nil

//------------------------------------------------------------------------------

//------------------------------------------------------------------------------

Function loadBmp(cUrl)
local oHttp
local cResp := nil

   Try
      oHttp := CreateObject( "winhttp.winhttprequest.5.1" )
      oHttp:Open("GET", cUrl, .f. )
      oHttp:Send()

      cResp := oHttp:ResponseBody()
      oHttp:WaitForResponse()

   Catch
      MsgStop( "Error" )
      Return cResp
   End Try

Return cResp

//------------------------------------------------------------------------------




Function llamada(cCity)
local oHttp
local cResp
local cDir
local Formato :=  "json"  // "xml"
local cUnits:= "c"

cDir := "https://query.yahooapis.com/v1/public/yql?q=select * from weather.forecast where woeid in (select woeid from geo.places(1)"
cDir:= cDir + " where text= '"+ cCity +"' ) and u='"+cUnits+"'&format=" + Formato

 Try
      oHttp := CreateObject("winhttp.winhttprequest.5.1")
      oHttp:Open("GET", cDir, .f. )
      oHttp:Send()
      cResp := oHttp:ResponseText()
         oHttp:WaitForResponse()
     // memowrit("eltiempo.txt",cResp )
     // msginfo("grabado")
     // winexec( "notepad.exe eltiempo.txt" )

     leejson( cResp )
   Catch
      MsgStop( "Error" )
      Return cResp
   End Try


Return nil

//------------------------------------------------------------------------------

function Leejson(cResp )
local hvar
local hvar1,hvar2
local cTexto:=""
local oDlg, cBmp
local nValor
local oBmp
local ofont1,ofont2
Local oBrwForecast


local i
local cImage,cMin,cMax,cData,cDay
local ahTexto,hDias,cPrev
local cUrl

hb_jsondecode( cResp, @hvar )

hvar1:= hvar["query"]["results"]["channel"]

 define font ofont1 name "Arial" size 0,16 bold

 DEFINE Font ofont2 NAME "Verdana" SIZE 0,13

 DEFINE DIALOG oDlg TITLE "Resultados" SIZE 500, 600 pixel color CLR_BLACK,CLR_WHITE


    @ 10 ,80 SAY alltrim(hvar1["title"] ) OF oDlg SIZE 180, 20 ;
                        pixel Font ofont1 color CLR_BLACK,CLR_WHITE

     @ 25, 70 SAY "Fecha : "+ alltrim(hvar["query"]["created"])  SIZE 180, 20 OF oDlg ;
                    pixel  color CLR_BLACK,CLR_WHITE FONT ofont2

     hvar2:= hvar1["wind"]

     @ 40, 100 say alltrim("Viento") SIZE 50, 20  OF oDlg  ;
                        pixel COLOR CLR_BLACK,CLR_WHITE FONT ofont1
     @ 50, 50 say alltrim("Sensacion Termica :" )  OF oDlg ;
               pixel color CLR_BLACK,CLR_WHITE FONT ofont2
     @ 50, 130 say alltrim( hVar2["chill"]+chr(186)+" "+ hvar1["units"]["temperature"] )  OF oDlg ;
              pixel color CLR_BLACK,CLR_WHITE FONT ofont2


     @ 60, 50 say "Direcccion " OF oDlg ;
             pixel  color CLR_BLACK,CLR_WHITE FONT ofont2
     @ 60, 130 say  hVar2["direction"]  OF oDlg ;
             pixel  color CLR_BLACK,CLR_WHITE FONT ofont2

     @ 70, 50 say "Velocidad "  OF oDlg ;
                     pixel  color CLR_BLACK,CLR_WHITE FONT ofont2

     @ 70, 130 say  hVar2["speed"]+" "+ hvar1["units"]["speed"]  OF oDlg ;
                     pixel  color CLR_BLACK,CLR_WHITE FONT ofont2


        hvar2:= hvar1["atmosphere"]


     @ 85, 95 say "Atmosfera " OF oDlg ;
                      pixel  color CLR_BLACK,CLR_WHITE FONT ofont1

     @ 100, 50 say "Humedad " OF oDlg ;
                    pixel  color CLR_BLACK,CLR_WHITE FONT ofont2
     @ 100, 130 say  hVar2["humidity"] + " %" OF oDlg ;
                    pixel  color CLR_BLACK,CLR_WHITE FONT ofont2


     @ 110, 50 say "Presion Barometrica " OF oDlg ;
                        pixel   color CLR_BLACK,CLR_WHITE FONT ofont2

     @ 110, 130 say hVar2["pressure"] + " "+ hvar1["units"]["pressure"] OF oDlg ;
                        pixel   color CLR_BLACK,CLR_WHITE FONT ofont2


     nValor:= hVar2["rising"]

     if  nValor == "0"
         cTexto := "Estable"
     elseif nValor == "1"
         cTexto := "Subiendo"
     elseif nValor == "2"
         cTexto := "Bajando"
     endif

     @ 120, 50 say "Tendencia Barometrica: "  OF oDlg ;
                        pixel color CLR_BLACK,CLR_WHITE FONT ofont2
     @ 120, 130 say cTexto OF oDlg ;
                        pixel color CLR_BLACK,CLR_WHITE FONT ofont2


      hvar2:= hvar1["astronomy"]



     @ 160, 30 say "Orto " + hVar2["sunrise"] OF oDlg ;
                         pixel color CLR_BLACK,CLR_WHITE FONT ofont2

     @ 160, 160 say "Ocaso " + hVar2["sunset"] OF oDlg ;
                         pixel color CLR_BLACK,CLR_WHITE FONT ofont2



      hvar2:= hvar1["item"]




aHTexto:=hVar2["forecast"]
nRow:=185
nCol:= 5
for i=1 to len(aHTexto)


hDias:=aHTexto[i]


cData:= hDias["date"]
cDay:= hDias["day"]
cMax:= hDias["high"]
cMin:= hDias["low"]
cPrev:= hDias["text"]
cUrl:= "http://l.yimg.com/a/i/us/we/52/"+hDias["code"]+".gif"




@ nRow,nCol say cData OF oDlg  pixel color CLR_BLACK,CLR_WHITE FONT ofont2
nRow+= 8
@ nRow,nCol say cDay OF oDlg  pixel color CLR_BLACK,CLR_WHITE FONT ofont2
nRow+= 8
@ nRow,nCol say cMax OF oDlg  pixel color CLR_BLACK,CLR_WHITE FONT ofont2
nRow+= 8
@ nRow,nCol say cMin OF oDlg  pixel color CLR_BLACK,CLR_WHITE FONT ofont2
nRow+= 8
 @ nRow,nCol say cPrev OF oDlg  pixel color CLR_BLACK,CLR_WHITE FONT ofont2
nRow+= 10

  @ nRow,nCol  IMAGE oBmp FILE cBmp OF oDlg size 32,32 pixel NOBORDER

      cargaBmp(cUrl,oBmp)

nCol+=50
nRow:=185
next








      cTexto:=hVar2["condition"]["code"]

      cTexto:="http://l.yimg.com/a/i/us/we/52/"+cTexto+".gif"

     @ 10,12  IMAGE oBmp FILE cBmp OF oDlg size 32,32 pixel NOBORDER

      cargaBmp(cTexto,oBmp)


    @ 280, 100 BUTTON "&Ok" SIZE 40, 12  OF oDlg pixel ;
      ACTION odlg:end() FONT oFont2

 ACTIVATE DIALOG oDlg CENTERED on paint  DlgStatusBar(oDlg, 68,, .t. )

  ofont1:end()
  ofont2:end()

 return nil

//------------------------------------------------------------------------------







//------------------------------------------------------------------------------

Function DlgStatusBar(oDlg, nHeight, nCorrec , lColor )
Local nDlgHeight := oDlg:nHeight
Local aColor     := { { 0.40, nRGB( 200, 200, 200 ), nRGB( 184, 184, 184 ) },;
                    { 0.60, nRGB( 184, 184, 184 ), nRGB( 150, 150, 150 ) } }

DEFAULT nHeight  := 72
DEFAULT nCorrec  := 0
DEFAULT lColor   := .F.

nDlgHeight:= nDlgHeight+ncorrec
IF lColor
   GradienTfill(oDlg:hDC,nDlgHeight-( nHeight-2 ),0,nDlgHeight-20,oDlg:nWidth, aColor ,.t.)
   WndBoxIn( oDlg:hDc,nDlgHeight-( nHeight-1 ),0,nDlgHeight-( nHeight ),oDlg:nWidth )
ELSE
   WndBoxIn( oDlg:hDc,nDlgHeight -( nHeight-1 ),4,nDlgHeight-( nHeight ),oDlg:nWidth - 10 )
endif

Return Nil

//------------------------------------------------------------------------------

FUNCTION DlgBarTitle( oWnd, cTitle, cBmp ,nHeight )
   LOCAL oFont
   LOCAL oTitle
   LOCAL nColText := 180
   LOCAL nRowImg  := 0


   DEFAULT cTitle  := ""
   DEFAULT nHeight := 48

   IF nHeight < 48
      nColText := 60
      nRowImg  := 12
      DEFINE FONT oFont NAME "Arial" size 10, 30
   ELSE
      DEFINE FONT oFont NAME "Arial" size 12, 30
   endif

    @ -1, -1  TITLE oTitle size oWnd:nWidth+1, nHeight+1 of oWnd SHADOWSIZE 0

   @  nRowImg,  10  TITLEIMG  OF oTitle BITMAP cBmp  SIZE 48, 48 REFLEX ;
          TRANSPARENT

    @  nRowImg-2 ,  nColText TITLETEXT OF oTitle TEXT cTitle COLOR CLR_BLACK FONT oFont

    oTitle:aGrdBack := { { 1, RGB( 255, 255, 255 ), RGB( 229, 233, 238 )  } }
    oTitle:nShadowIntensity = 0
    oTitle:nShadow = 0
    oTitle:nClrLine1 := nrgb(0,0,0)
    oTitle:nClrLine2 := RGB( 229, 233, 238 )
    oWnd:oTop:= oTitle



RETURN oTitle

 

Re: un pequeño ejemplo ...meteo.prg

PostPosted: Tue Dec 09, 2014 9:36 pm
by mastintin
Silvio . Yeaaaaa very very good :shock: :D

Re: un pequeño ejemplo ...meteo.prg

PostPosted: Tue Dec 09, 2014 9:48 pm
by Silvio.Falconi
Image

other modifies
Code: Select all  Expand view

aHTexto:=hVar2["forecast"]
nRow:=185
nCol:= 5
for i=1 to len(aHTexto)
hDias:=aHTexto[i]
cData:= hDias["date"]
cDay:= hDias["day"]
cMax:= hDias["high"]
cMin:= hDias["low"]
cPrev:= hDias["text"]
cUrl:= "http://l.yimg.com/a/i/us/we/52/"+hDias["code"]+".gif"
@ nRow,nCol say cData OF oDlg  pixel color CLR_BLACK,CLR_WHITE FONT ofont2
nRow+= 8
@ nRow,nCol+15 say cDay OF oDlg  pixel color CLR_BLACK,CLR_WHITE FONT ofont2
nRow+= 8
@ nRow,nCol+15 say cMax OF oDlg  pixel color CLR_BLACK,CLR_WHITE FONT ofont2
nRow+= 8
@ nRow,nCol+15 say cMin OF oDlg  pixel color CLR_BLACK,CLR_WHITE FONT ofont2
nRow+= 8
@ nRow,nCol say cPrev OF oDlg  pixel color CLR_BLACK,CLR_WHITE FONT ofont2
nRow+= 10
@ nRow,nCol  IMAGE oBmp FILE cBmp OF oDlg size 32,32 pixel NOBORDER
cargaBmp(cUrl,oBmp)
nCol+=50
nRow:=185
next

@ 170, 2 GROUP oGroup TO 260,248 LABEL "Forecast Week" OF oDlg  pixel TRANSPARENT




when the data hDias["text"] is small it is not on center ...how I can resolve it ?

Re: un pequeño ejemplo ...meteo.prg

PostPosted: Tue Dec 09, 2014 10:07 pm
by Silvio.Falconi
Another Manuel,
why the text are on english language ?
is there a code to set the language ?
on https://developer.yahoo.com/weather/doc ... html#codes I not found the language

but on https://developer.yahoo.com/weather/ I see the lang

Code: Select all  Expand view
"query": {
  "count": 1,
  "created": "2014-12-09T22:13:09Z",
  "lang": "it-IT",
  "results": {
   "channel": {
    "title": "Yahoo! Weather - Nome, AK",
    "link": "http://us.rd.yahoo.com/dailynews/rss/weather/Nome__AK/*http://weather.yahoo.com/forecast/USAK0170_f.html",
    "description": "Yahoo! Weather for Nome, AK",
    "language": "en-us",
    "lastBuildDate": "Tue, 09 Dec 2014 8:54 am AKST",
    "ttl": "60",
    "location": {
     "city": "Nome",
     "country": "United States",
     "region": "AK"
    },


there is hvar1["language"] at hvar1:= hvar["query"]["results"]["channel"]

I add afet the title
@ 10 ,190 SAY alltrim(hvar1["language"] ) OF oDlg SIZE 180, 20 ;
pixel Font ofont1 color CLR_BLACK,CLR_WHITE

and return me en_Us

How we can set the lang on texts ?

or we must translate this on Italian or Germany or Espanol... only english ?
Code Description
0 tornado
1 tropical storm
2 hurricane
3 severe thunderstorms
4 thunderstorms
5 mixed rain and snow
6 mixed rain and sleet
7 mixed snow and sleet
8 freezing drizzle
9 drizzle
10 freezing rain
11 showers
12 showers
13 snow flurries
14 light snow showers
15 blowing snow
16 snow
17 hail
18 sleet
19 dust
20 foggy
21 haze
22 smoky
23 blustery
24 windy
25 cold
26 cloudy
27 mostly cloudy (night)
28 mostly cloudy (day)
29 partly cloudy (night)
30 partly cloudy (day)
31 clear (night)
32 sunny
33 fair (night)
34 fair (day)
35 mixed rain and hail
36 hot
37 isolated thunderstorms
38 scattered thunderstorms
39 scattered thunderstorms
40 scattered showers
41 heavy snow
42 scattered snow showers
43 heavy snow
44 partly cloudy
45 thundershowers
46 snow showers
47 isolated thundershowers
3200 not available

Re: un pequeño ejemplo ...meteo.prg

PostPosted: Tue Dec 09, 2014 10:38 pm
by mastintin
Silvio por el momento Yahoo solo funciona en ingles.

Re: un pequeño ejemplo ...meteo.prg

PostPosted: Tue Dec 09, 2014 11:20 pm
by Silvio.Falconi
Manuel,
I tried .. I am on yahoo console and I try to insert Lang="it-IT" and here run ok


https://developer.yahoo.com/yql/console ... D%22sfo%22

for a sample

select * from geo.places where text="Teramo,Ab" and lang="it-IT"

return right me I put in bold italian text

{
"query": {
"count": 1,
"created": "2014-12-09T23:21:40Z",
"lang": "en-US",
"diagnostics": {
"publiclyCallable": "true",
"url": {
"execution-start-time": "1",
"execution-stop-time": "18",
"execution-time": "17",
"content": "http://wws.geotech.yahooapis.com/v1/places.q(Teramo%2CAb);start=0;count=10?lang=it-IT"
},
"user-time": "18",
"service-time": "17",
"build-version": "0.2.212"
},
"results": {
"place": {
"lang": "it-IT",
"uri": "http://where.yahooapis.com/v1/place/724792",
"woeid": "724792",
"placeTypeName": {
"code": "7",
"content": "Città"
},
"name": "Teramo",
"country": {
"code": "IT",
"type": "Paese",
"woeid": "23424853",
"content": "Italia"
},
"admin1": {
"code": "",
"type": "Regione",
"woeid": "7153350",
"content": "Abruzzi"
},
"admin2": {
"code": "IT-TE",
"type": "Provincia",
"woeid": "12591815",

"content": "Teramo"
},
"admin3": {
"code": "",
"type": "Comune",
"woeid": "12676370",
"content": "Teramo"
},
"locality1": {
"type": "Città",
"woeid": "724792",
"content": "Teramo"
},
"locality2": null,
"postal": {
"type": "Codice Postale",
"woeid": "12846808",
"content": "64100"
},
"centroid": {
"latitude": "42.660728",
"longitude": "13.706400"
},
"boundingBox": {
"southWest": {
"latitude": "42.653450",
"longitude": "13.682890"
},
"northEast": {
"latitude": "42.668060",
"longitude": "13.729030"
}
},
"areaRank": "1",
"popRank": "10",
"timezone": {
"type": "Fuso Orario",
"woeid": "28350914",
"content": "Europe/Rome"
}
}
}
}
}
THE REST QUERY How do I use this?