IonicWind Software

IWBasic => General Questions => Topic started by: Robert34 on June 06, 2011, 02:42:38 PM

Title: Check website for updates
Post by: Robert34 on June 06, 2011, 02:42:38 PM
When a person starts my IWBasic program, is there a way to automatically poll my website to see if there is an update?

Thanks,

Robert
Title: Re: Check website for updates
Post by: LarryMc on June 06, 2011, 03:09:30 PM
The obvious answer is yes.  But I've never actually done it.
About 10 years ago I had a webpage that called a cgi program on aol's server.

You'd need a cgi type program to respond to the web message posted by your program.

There are people around here that know a lot more about that stuff than I do.

LarryMc
Title: Re: Check website for updates
Post by: King64 on June 07, 2011, 12:53:02 AM
One way to see if there is an update for your program would be to read a file containing a string and compare it with that version of the program. If they are different then you would proceed with the update. Below is a simple code that reads a text file and prints it when the reading is successful. The program, IBasic old code, was tested on a local web server.

' Create an import library from wininet.dll before running this program!
$USE "wininet.lib"

SETID "INTERNET_SERVICE_HTTP",3
SETID "INTERNET_PRECONFIG",0
SETID "INTERNET_FLAG_RELOAD",0x80000000

DECLARE "wininet",InternetOpenA(agent:STRING,access:INT,proxyname:STRING,proxybypass:STRING,flags:INT),INT
DECLARE "wininet",InternetConnectA(session:INT,server:STRING,port:word,username:STRING,pass:STRING,service:INT,flags:INT,context:INT),INT
DECLARE "wininet",InternetCloseHandle(handle:INT),INT
DECLARE "wininet",HttpOpenRequestA(session:INT,verb:STRING,name:STRING,version:POINTER,referer:STRING,types:POINTER,flags:INT,context:INT),INT
DECLARE "wininet",HttpSendRequestA(handle:INT,headers:POINTER,headerlength:INT,option:POINTER,optionlength:INT),INT
DECLARE "wininet",InternetReadFile(hfile:INT,buffer:STRING,count:INT,bytesread:POINTER),INT

STRING ret

' tested on http://localhost
ret=GetVersion("127.0.0.1","version.txt")
IF ret="" THEN PRINT "Errore" ELSE PRINT ret
DO:UNTIL INKEY$<>""
END

SUB GetVersion(site$:STRING,doc$:STRING),STRING

INT br
INT avail
INT hopen
INT hhttp
  INT hconnect
  STRING ref$
STRING buffer
STRING content
POINTER null

'if the url you want is "http://www.yourdomain.com/yourversion/version.txt", then
'site$ must be "www.yourdomain.com"
'doc$ must be "yourversion/version.txt"
'the doc$ refers to the actual document, directory or page being retrieved.

ref$ = "MyAgent" : ' Your agent name for the connection
content = ""
hopen = InternetOpenA(ref$,@INTERNET_PRECONFIG,"","",0)
IF hopen
'messagebox main, "Wininet initialized", ""
hconnect = InternetConnectA(hopen,site$,80,"","",@INTERNET_SERVICE_HTTP,0,0)
IF hconnect
'messagebox main, "Connection established", ""
hhttp = HttpOpenRequestA(hconnect,"GET",doc$,null,"",null,@INTERNET_FLAG_RELOAD,0)
IF hhttp
IF HttpSendRequestA(hhttp,null,0,null,0)
'messagebox main, "Request Made", ""
DO
InternetReadFile(hhttp,buffer,255,br)
buffer = left$(buffer,br)
  'messagebox main, buffer, ""
IF br THEN content = content + buffer
buffer = ""
UNTIL br = 0
ENDIF
InternetCloseHandle(hhttp)
ENDIF
InternetCloseHandle(hconnect)
ENDIF
InternetCloseHandle(hopen)
ENDIF
RETURN content

ENDSUB



:)
Title: Re: Check website for updates
Post by: Robert34 on June 08, 2011, 06:42:58 AM
Thank you, King64.  That's a very good idea.
-- Robert