1

Konu: Form Üzerinde Html Sayfada Döviz Kurları Gösterimi

Arkadaşlar kendimde kullanmayı düşündüğüm bir sey geliştirdim sizlerlede paylaşmak istedim

Visual Fox Pro
PUBLIC odaily_currency

 
odaily_currency=NEWOBJECT("daily_currency")
odaily_currency.Show
RETURN
 
 
    **************************************************
*-- Form:         daily_currency (d:\soykan\mysoftware\depomatik\form\daily_currency.scx)
*-- ParentClass:  form
*-- BaseClass:    form
*-- Time Stamp:   02/15/10 11:35:04 AM
*
DEFINE CLASS daily_currency AS form
 
 
    Top = 0
    Left = 0
    Height = 410
    Width = 211
    DoCreate = .T.
    Tag = "daily_currency"
    BorderStyle = 0
    Caption = "Döviz Kurları"
    MaxButton = .F.
    MinButton = .F.
    Movable = .F.
    Icon = "..\static\vs_ico.ico"
    Name = "daily_currency"
 
 
    ADD OBJECT oie AS olecontrol WITH ;
        Top = 0, ;
        Left = 0, ;
        Height = 410, ;
        Width = 210, ;
        Name = "OIE",;
     OleClass = 'Shell.Explorer'
 
 
 
    PROCEDURE Destroy
        ERASE 'doviz.htm'
        ERASE 'NoDoviz.htm'
    ENDPROC
 
 
    PROCEDURE Init
        Local lcDovizHtml,lcNoDovizHtml
        lcDovizHtml = Sys(5)+Curdir()+'doviz.htm'
        lcNoDovizHtml = Sys(5)+Curdir()+'Nodoviz.htm'
 
        Local lcURL
        lcURL=[http://www.google.com/]
 
        Declare Integer InternetCheckConnection In Wininet.Dll String Url, Long dwFlags, Long Reserved
        If InternetCheckConnection(lcURL, 1, 0) != 0
            *Return .T.
            TEXT TO m.lcDoviz TEXTMERGE noshow
        <script type="text/javascript" src="http://www.doviz.com/script/widget.js">
        </script>
        <script type="text/javascript">_dovizCurrency('USD_EUR','','http://www.doviz.com/')</script>
        <div style="width:100%;text-align:center;font-size:11px">
        <a style="text-decoration:none;color:#000000" href="http://www.doviz.com/" title="Döviz, Dolar, Euro, Sterlin" target="_blank">
        </a>
        </div>
            ENDTEXT
 
 
            If ! File('doviz.htm')
                Strtofile(m.lcDoviz,m.lcDovizHtml)
            Endif
 
            With Thisform.OIE
                .Navigate2('file://'+m.lcDovizHtml)
                Do While .ReadyState # 4 && Wait for ready state
                Enddo
            Endwith
 
        Else
            *Return .F.
            *Messagebox('bla bla',16,_Screen.Caption)
            Local NoInternetImage
            NoInternetImage = 'static/internet-main_full.jpg'
 
            TEXT TO m.lcNoDoviz TEXTMERGE noshow
        <html>
        <head>
        <title>Doviz Kurları</title>
        <style type="text/css">
        .Soykan {
        font-family:,Georgia,ms trebuchet,tahoma,Verdana, Arial, Helvetica, sans-serif;
        font-size:12px;
        font-weight: bold;
        color:Red;
        text-align:center;
        }
        .GreyBox {border: 1px solid #CCCCCC;}
        #fox4um
        {
            width:160px;
            height:330px;
            padding:1px;
        }
        </style>
        </head>
        <body>
        <div id="fox4um"class="GreyBox">
        <span class="Soykan">Internet Baglantiniz Yok !!! </span>
        <br />
        <img src= "static/internet-main_full.jpg" width="159" height="329" /></img>
        </div>
        </body>
        </html>
            ENDTEXT
 
            If ! File('NoDoviz.htm')
                Strtofile(m.lcNoDoviz,m.lcNoDovizHtml)
            Endif
 
 
            With Thisform.OIE
                .Navigate2('file://'+m.lcNoDovizHtml)
                Do While .ReadyState # 4 && Wait for ready state
                Enddo
            Endwith
        Endif
 
        With This As Form
            .Width = .OIE.Width
            .Height = .OIE.Height
            .Left = (Sysmetric(1)-.Width)-10
        Endwith
    ENDPROC
 
 
ENDDEFINE
*
*-- EndDefine: daily_currency
**************************************************

2 Son düzenleyen, ugurlu2001 (15.02.2010 12:17:52)

Re: Form Üzerinde Html Sayfada Döviz Kurları Gösterimi

Soykan abi kod çalışmıyor ( yada bende bir sorun var ) Daha doğrusu ekranda bir şey göstermiyor

Uğur
-------------------------------------------------------------------------------------------------------------
Hayat bir bisiklete binmek gibidir. Pedalı çevirmeye devam ettiğiniz sürece düşmezsiniz. Claude Peppeer
Kusuru söylenmeyen adam, ayıbını hüner sanır.  Türk Atasözü

3

Re: Form Üzerinde Html Sayfada Döviz Kurları Gösterimi

doviz.htm olusmus ise gostermesi gerek

4

Re: Form Üzerinde Html Sayfada Döviz Kurları Gösterimi

ben test ettim çok güzel çalışıyor gerçekten işe yarayacak bir kod

5

Re: Form Üzerinde Html Sayfada Döviz Kurları Gösterimi

Soykan bey kod bende çalışıyor. Gayet güzel olmuş. Elinize bilginize sağlık.

6

Re: Form Üzerinde Html Sayfada Döviz Kurları Gösterimi

Bu da aynı siteden veriyi XML olarak alan kod:

Visual Fox Pro
clea

create cursor xmlcurs1(kod c(3),adi c(20),alis c(6),satis c(6),saat c(20),b c(35))
xurl1="http://www.doviz.com/feed/doviz.php?bank=free"
oxml=createobject("msxml2.domdocument")
oxml.async=.f.
oxml.load(xurl1)
xsaat="-"
xmlkatoku(oxml,2)
delete for alltrim(xmlcurs1.adi)="DOVIZ.COM"
brow
retu
 
 
************************
proc xmlkatoku(okat,xmc)
    for each mkat in okat.childnodes
        if mkat.nodetype<3 and mkat.childnodes.length=1
            nn=upper(allt(mkat.nodename))
            mt=upper(allt(mkat.text))
            do case
                case nn="PUBDATE"
                    xsaat=left(right(mt,14),8)
                case nn="TITLE"
                    append blank
                    replace adi with mt
                    replace saat with xsaat
                    xkod="-"
                    do case
                        case mt="AVUSTRALYA"
                            xkod="AUD"
                        case mt="KANADA"
                            xkod="CAD"
                        case mt="İSVIÇRE"
                            xkod="CHF"
                        case mt="İNGILIZ"
                            xkod="GBP"
                        case mt="JAPON"
                            xkod="JPY"
                        case mt="NORVEÇ"
                            xkod="NOK"
                        case mt="DANIMARKA"
                            xkod="DKK"
                        case mt="EURO"
                            xkod="EUR"
                        case mt="ARABISTAN"
                            xkod="SAR"
                        case mt="İSVEÇ"
                            xkod="SEK"
                        case mt="AMERIKAN"
                            xkod="USD"
                        case mt="ÇIN"
                            xkod="CNY"
                        case mt="RUS"
                            xkod="RUB"
                        case mt="IRAK"
                            xkod="IQD"
                    endcase
                    replace kod with xkod
                case nn="DESCRIPTION"
                    replace b with mt
                    xcal=alltrim(strextract(mt,'ALıŞ','TL',1,1))
                    xsat=alltrim(strextract(mt,'SATıŞ:','TL',1,1))
                    replace alis  with xcal
                    replace satis with xsat
            endcase
        endif
        if (mkat.haschildnodes)
            xmlkatoku(mkat,xmc+1)
        endif
    next
endproc


Kod daha uzundu, gereksiz kısımları ayıklamaya çalıştım. Anlamsız parçalar kalmış olabilir.

7

Re: Form Üzerinde Html Sayfada Döviz Kurları Gösterimi

Birol alternatif kod için teşekkür bu aklıma başka bir şey getirdi smile

arkadaslar ayrica
<script type="text/javascript">_dovizCurrency('USD_EUR','','http://www.doviz.com/')</script>
satirindaki USD_EUR yi USD_EUR_GBP_JPY gibi degistirerek daha fazla döviz gösterebilirsiniz

8

Re: Form Üzerinde Html Sayfada Döviz Kurları Gösterimi

ben yıllardır TCMB kullanıyorum.
kurları aşağıdaki kodla alabiliyorum, kodun kaynağını hatırlayamadım

Visual Fox Pro
lcURL = "http://www.tcmb.gov.tr/kurlar/today.xml"

 
oForm = Createobject('readxml', m.lcURL)
Select Doviz
browse
COPY TO den
 
Define Class readxml As Form
Add Object htmlviewer As OleControl With ;
OleClass = 'Shell.Explorer'
 
Procedure Init
Lparameters tcURL
With Thisform.htmlviewer
.Navigate2(m.tcURL)
Do While .ReadyState # 4 && Wait for ready state
EndDo
XMLToCursor(this.htmLVIEWER.Object.Document.XMLDocument.XML,'Doviz')
Return .F.
Endwith
Endproc
Enddefine
VFP9 SP2

9

Re: Form Üzerinde Html Sayfada Döviz Kurları Gösterimi

Ben de sanirim bu kodu birisi sordugu icin yazmistim ve sonra Foxite'da bir tartisma nedeniyle biraz daha gelismisti diye hatirliyorum:

Visual Fox Pro
GetDailyCurrencies() && date(), doviz - bugun, 'doviz' adli cursore

Select doviz
Browse
 
GetDailyCurrencies(DATE()-10,'myCursor') && 10 gun oncesini 'myCursor' adli cursore
Select myCursor
Browse
 
 
PROCEDURE GetDailyCurrencies(tdDate,tcCursorName)
tdDate = EVL(m.tdDate,DATE())
tcCursorName = EVL(m.tcCursorName,'doviz')
Local lcURL,lcLocalFile,lcXML,lnSelect
lcURL = "http://www.tcmb.gov.tr/kurlar/"
If m.tdDate = Date()
  lcURL = m.lcURL + "today.xml"
Else
  lcURL = m.lcURL +   ;
    Left(Ttoc(m.tdDate,1),6)+"/"+;
    PADL(Day(m.tdDate),2,'0')+;
    PADL(Month(m.tdDate),2,'0')+;
    padl(Year(m.tdDate),4)+".xml"
Endif
 
lnSelect = SELECT()
lcLocalFile = Forcepath(Sys(2015)+'.xml',Sys(2023))
If getFileFromURL(m.lcURL,m.lcLocalFile) = 0
  lcXML = Filetostr(m.lcLocalFile)
  Erase (m.lcLocalFile)
  ParseDoviz(m.lcXML,tcCursorName)
ENDIF
SELECT (m.lnSelect)
 
Procedure getFileFromURL
  Lparameters tcRemoteFile,tcLocalFile
  Declare Integer URLDownloadToFile In urlmon.Dll;
    INTEGER pCaller, String szURL, String szFileName,;
    INTEGER dwReserved, Integer lpfnCB
  Return URLDownloadToFile(0, m.tcRemoteFile, m.tcLocalFile, 0, 0)
 
 
Procedure ParseDoviz(tcXML,tcCursorName)
  Local lcCurrencyCode
  Local Array aReplacement[OCCURS('<Currency ',m.tcXML),2]
  For ix=1 To Occurs('<Currency ',m.tcXML)
    lcCurrencyCode = Strextract(m.tcXML,'<Currency ','>',m.ix,1+4)
    aReplacement[m.ix,1] = m.lcCurrencyCode
    aReplacement[m.ix,2] = ;
      GETWORDNUM(m.lcCurrencyCode,1)+'>'+;
      '<Kod>'+Strextract(Getwordnum(m.lcCurrencyCode,2),'"','"')+'</Kod>'+;
      '<CurrencyCode>'+Strextract(Getwordnum(m.lcCurrencyCode,3),'"','"')+'</CurrencyCode>'
  Endfor
  For ix=1 To Alen(aReplacement,1)
    m.tcXML = Strtran(m.tcXML,aReplacement[m.ix,1],aReplacement[m.ix,2])
  Endfor
  Xmltocursor(m.tcXML,m.tcCursorName)
Endproc

10

Re: Form Üzerinde Html Sayfada Döviz Kurları Gösterimi

kurlari bir tabloda saklamak ve uygulama icinde kullanmak icin bende Cetin hocamin kodlarini kullaniyorum ,
buda serbest piyasa + bankalarin verilerini görsel olarak göstermek için yaptığım bir çalışma idi.