Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Read INI's from web server?
#1
I want to know if it's possible to read INI data from a webserver or FTP.

I know how to read files, I just don't knwo how to read specific information from them. Example:

I want to open News.ini from valaron.awardspace.com

News.ini looks like this:

Code:
[News]
News=No news for today, sorry!

[MOTD]
Motd=Message of the day: You are here!

I want to read the news and show it on the main menu, then after log in, read the Motd and display it in the chat box... just not sure how I would do that.

Any help would be appreciated Smile
Reply
#2
yea i think it is possible.. but this is how i would do it =p i would put a control for webbrowser in my program and make it invisible so u only receive information from it like that
Reply
#3
Mind explaining that... or to steal a quite from you "yea ok i cant find any tutorials so can some1 juss gimmi the codes like the subs/functions/types"
Reply
#4
use INet to download the file from the webserver, then use putvar/getvar.

thats what hes saying, and yes, it will work.
Reply
#5
You might be able to substitute the app.path part, with the inet url, and maybe, it will work. I will try in a bit.
Reply
#6
Easy.

Upload a html with your news in and call it news.html

In componts look for thease
[Image: msconpbb4.gif]

put then both in the projects form where you want them.

Call the browser brow1

add this code to form load
Code:
brow1.navigate "http://urlhere"
If you want it to activate on command click then it will be

Code:
Private sub cmdbutton_click
browser1.navigate "urlhere"
end sub

I cleaned this up, if you have any questions just ask Big Grin
Reply
#7
Okay, I'll try that when I get the chance, thanks.
Reply
#8
Okay, that reads the stuff, but the game won't read it as an ini file.

Does anyone know how to read an ini type file from a text box in VB?
Reply
#9
inis are slow, thats alot easier. No need to update the ini just the webpage Big Grin
Reply
#10
I don't see how that would work, maybe you could explain it to me. And if you want faster, just go with access or go with mysql.
Reply
#11
What this does is reads directly from a webpage. The two componatns i tell you to add is to allow a webpage in your form. This is a very simple tutrorial but i used this to make my webbrowser for my school project Big Grin
Reply
#12
Code:
Public Function DownloadFile(srcFileName As String, targetFileName As String)
Dim Size As Long, Remaining As Long, FFile As Integer, Chunk() As Byte

If Trim(targetFileName)  "" Then
    If Extension  "" Then
        If Mid(Extension, 1, 1) = "\" Or Mid(Extension, 1, 1) = "/" Then Extension = Mid(Extension, 2, Len(Extension))
        If Mid(Extension, Len(Extension), Len(Extension)) = "\" Or Mid(Extension, Len(Extension), Len(Extension)) = "/" Then Extension = Mid(Extension, 1, Len(Extension) - 1)
        
        If LCase(Dir(App.Path & "\" & Extension, vbDirectory))  LCase(Extension) Then
            Call MkDir(App.Path & "\" & Extension)
        End If
    Else
        targetFileName = targetFileName
    End If
        
    frmUpdate.Inet.Execute Path & srcFileName, "GET"

    Do While frmUpdate.Inet.StillExecuting
        DoEvents
    Loop

    Size = Val(frmUpdate.Inet.GetHeader("Content-Length"))
    Remaining = 0
    FFile = FreeFile
    
    If Extension  "" Then
        Open App.Path & "\" & Extension & "\" & targetFileName For Binary Access Write As #FFile
    Else
        Open App.Path & "\" & targetFileName For Binary Access Write As #FFile
    End If
    Do Until Remaining >= Size
        If Size - Remaining > 1023 Then
            Chunk = frmUpdate.Inet.GetChunk(1024, icByteArray)
            Remaining = Remaining + 1024
        Else
            Chunk = frmUpdate.Inet.GetChunk(Size - Remaining, icByteArray)
            Remaining = Size
        End If
     Put #FFile, , Chunk

     If Size > 0 Then frmUpdate.Label4.Caption = Int(Str((Remaining / Size) * 100)) & "%"
         Loop
    Close #FFile
    
    DoEvents
End If
End Function

thats from GSDs old updater, you should have no problem figuring out what needs to be chhanged around. (frmUpdate and removal of albels you dont have). It downloads the file to your directory and you can read it from there.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)