Post by atomose on Dec 1, 2022 3:26:18 GMT -5
Hi !
Here is a code to put in your programs / games and which allows you to automatically update them.
All you need is a host (I recommend www.petit-fichier.fr) and put a txt file on it.
The file will consist of 2 lines:
- the version number
- the download link
on this same host, you then put your updates.
Then, just modify the txt file (the version number) for the updates to be made. the code will go to see the txt file, compare the version of the current software and that on the host and if it is more recent, it will download it.
It's a very basic way to keep their software up to date if the person doesn't want to search on the site (just put a button on the program that redirects to the update).
If you have any ideas for improvements I'm interested ^^
Here is a code to put in your programs / games and which allows you to automatically update them.
All you need is a host (I recommend www.petit-fichier.fr) and put a txt file on it.
The file will consist of 2 lines:
- the version number
- the download link
on this same host, you then put your updates.
Then, just modify the txt file (the version number) for the updates to be made. the code will go to see the txt file, compare the version of the current software and that on the host and if it is more recent, it will download it.
It's a very basic way to keep their software up to date if the person doesn't want to search on the site (just put a button on the program that redirects to the update).
If you have any ideas for improvements I'm interested ^^
[maj]
GameVersion = 1.0 'your game/program version
on error goto [error]
htmlText$ = httpget$("download link (must be a txt file)")
if htmlText$ <> "" then run "curl -O link_to_txt_file"
if htmlText$ = "" and version =2 then notice " " + chr$(13) + "Server unavailable" : wait
htmlText$ =""
call Sleep 1000 : goto [maj2]
[maj2]
open "txt_file" for input as #secu
input #secu, GameVersionNEW
input #secu, LinkDownloadNewVersion$
close #secu
call Sleep 500 : goto [maj3]
[maj3]
TXT1$ = " You have version ";GameVersion;"."
TXT2$ = " Last downloadable version is ";GameVersionNEW;"."
notice " " + chr$(13) + TXT1$ + chr$(13) + chr$(13) + TXT2$
if GameVersionNEW > GameVersion then
run "curl -O ";LinkDownloadNewVersion$
call Sleep 800
dir$ = "" : file$ = "txt_file"
if fileExist(dir$,file$) = 1 then kill "txt_file"
call Sleep 200
notice " " + chr$(13) + "Download complete." + chr$(13) + "The new version is available in the game folder." + chr$(13) + chr$(13) + "Closing the current version."
close #ini : end
end if
if GameVersionNEW <= GameVersion then notice " " + chr$(13) + "You have the latest update."
dir$ = "" : file$ = "txt_file"
if fileExist(dir$,file$) = 1 then kill "txt_file"
[error]
wait
Sub Sleep ms
CallDLL #kernel32, "Sleep",_
ms as long,_
ret as void
End Sub