Some Potentially Useful Code
CMPC :: Computing :: Programming :: General Coding
Page 1 of 1
Some Potentially Useful Code
It's in BASIC, but the principle should carry over to most other languages.
This first one is used to track time a program has been run.
This code is for autoupdating.
filelist.txt
Basically, it reads the version, and if it's different, downloads the listed files from the server, replacing the old ones.
This first one is used to track time a program has been run.
- Code:
exec("updsrv.uti","") 'This runs the program in the code box below...
dim x as integer
dim y as integer
x = timer 'timer return a double with the seconds since midnight
exec ("engine.exe","0192837465") 'this starts the game, or any other program you want
y = timer - x 'sees the time past in seconds
OPEN "cli.exe.log" FOR APPEND AS #1
PRINT #1, date ; " "; time; " for ";int(y/60);":";y mod 60 'write the time to a file, appending
CLOSE #1
This code is for autoupdating.
- Code:
screenres 300,150,32
dim as integer f, num, prog
dim files(100) as string
dim upnum as string
dim as string oldver, newver
print "Checking for updates..."
exec ("getfile.uti", "filelist.txt filelst") 'this downloads a file from the server, see below code block
f = freefile
open "filelst" for input as #f
line input #f, newver
line input #f, upnum
for num = 0 to val(upnum) - 1
line input #f, files(num)
next num
close #f
kill "filelst"
open "updver" for input as #f
line input #f, oldver
close #f
print
if oldver = newver then
print "No updates found."
print "Exiting..."
sleep 3000,1
end
end if
print upnum; " updates available."
print "Downloading updates..."
print "Updating from version ";oldver; " to ";newver
line(9,54)-(211,86),rgb(255,0,0),b 'b means make a box instead of line
locate 9,28:print " 0.00%"
for num = 0 to val(upnum) - 1
exec ("getfile.uti", files(num) & " " & files(num))
line(10,55)-((((num +1)/ val(upnum)) * 200)+10,85),rgb(0,255,0),bf 'means make a filled box instead of line
locate 9,28:print using "###.##\ \";(((num +1)/ val(upnum))*100),"%"
next num
open "updver" for output as #f
print #f, newver
close #f
print:print
print "Automatic updates complete."
sleep 500,1
filelist.txt
- Code:
0001
4
image2.bmp
program1.exe
music1.mp3
text1.txt
Basically, it reads the version, and if it's different, downloads the listed files from the server, replacing the old ones.
Corey- Mod
- Posts : 462
CMPC :: Computing :: Programming :: General Coding
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|