Xander Posted April 7, 2005 Share Posted April 7, 2005 (edited) The script is pretty obvious, I think. I'm new to scripting and I'm trying to keep it lean (and self-educational) at the same time.The errors I'm getting has to do with, I'm pretty sure, the mis-use of the Dim statement. What should it be? Any suggestions on how I can clean this up?Error: Variable used without being declared;Script's purpose is to check for updates online. ;If file sizes don't match, assume there's an update and download it to the directory.XCleaner()Blockfile()HijackThis()ExitFunc HijackThis()Dim $name='HijackThis.exe'Dim $site='http://www.spywareinfo.com/~merijn/files/' & $nameDim $dir='F:\System CD\Spy\' & $name Seek()EndFuncFunc Blockfile()Dim $name='blocklist.reg'Dim $site='http://www.spywareguide.com/' & $nameDim $dir='F:\System CD\Spy\' & $name Seek()EndFuncFunc xcleaner()Dim $name='xclean_micro.exe'Dim $site='http://www.xblock.com/download/' & $nameDim $dir='F:\System CD\Spy\' & $name Seek()EndFuncFunc Seek() msgbox("Size", $site, $dir)$sizeweb = InetGetSize($site)$sizehome = FileGetSize($dir)if $sizeweb <> $sizehome Then TrayTip("Updating",$name,3) InetGet($site,$dir,1,0) EndIfEndFunc Edited April 8, 2005 by Xander Link to comment Share on other sites More sharing options...
Xander Posted April 8, 2005 Author Share Posted April 8, 2005 Anybody? Anybody? Bueller? Link to comment Share on other sites More sharing options...
bshoenhair Posted April 8, 2005 Share Posted April 8, 2005 One Way: expandcollapse popup;Script's purpose is to check for updates online. ;If file sizes don't match, assume there's an update and download it to the directory. Global $name Global $site Global $dir XCleaner() Blockfile() HijackThis() Exit Func HijackThis() $name='HijackThis.exe' $site='http://www.spywareinfo.com/~merijn/files/' & $name $dir='F:\System CD\Spy\' & $name Seek() EndFunc ;==>HijackThis Func Blockfile() $name='blocklist.reg' $site='http://www.spywareguide.com/' & $name $dir='F:\System CD\Spy\' & $name Seek() EndFunc ;==>Blockfile Func xcleaner() $name='xclean_micro.exe' $site='http://www.xblock.com/download/' & $name $dir='F:\System CD\Spy\' & $name Seek() EndFunc ;==>xcleaner Func Seek() msgbox("Size", $site, $dir) $sizeweb = InetGetSize($site) $sizehome = FileGetSize($dir) if $sizeweb <> $sizehome Then TrayTip("Updating",$name,3) InetGet($site,$dir,1,0) EndIf EndFunc ;==>Seek Link to comment Share on other sites More sharing options...
Xander Posted April 8, 2005 Author Share Posted April 8, 2005 (edited) My mistake was the not understanding the GLOBAL command.I'd seen it in examples of "Global $var = ..." and thought that the variable had to be defined at the start, and that that variable was then unchanging throughout the whole script. Before coming back here, I had just tried using Global instead of Dim or Local before my vars and it had worked. Your suggestion shaves off a few characters overall. One more thing learned!I already have the compiled script set up as a weekly task to keep my install files up to date.While there might be better ways to determing whether or not an update is available (small chance that the update is the exact same size as the last one), this seems to work quite well.Incidentally, if anyone can suggest any other commonly used files, I'd be glad to hear from you. Edited April 8, 2005 by Xander Link to comment Share on other sites More sharing options...
busysignal Posted April 8, 2005 Share Posted April 8, 2005 bshoenhair, Nice and simple rearrangement of code. It works great after I modifed it for some programs that I use. Also, I have been thinking of doing some similar code, but you all beat me to it. Thanks for the thread... Always leaning something new.. Cheers. :-) Link to comment Share on other sites More sharing options...
busysignal Posted April 8, 2005 Share Posted April 8, 2005 Incidentally, if anyone can suggest any other commonly used files, I'd be glad to hear from you.<{POST_SNAPBACK}>Here are some utils that I really like to add to my system. Some are XP-only apps.http://www.xp-antispy.org - XP-Antispy - Disables M$ Spy functionalityhttp://www.aignes.com/deadlink.htm - AMDeadLink - Bookmark Managerhttp://www.daemon-tools.cc/dtcc/portal/portal.php - Daemon Tools - CD Emulatorhttp://www.larshederer.homepage.t-online.de/erunt/ - ERUNT - Registry/Profile backup util (Saved my butt many times)http://scintilla.sourceforge.net/SciTEDoc.html - SciTE - AutoIt EditorHope you find these of interest.. BTW, they are all FreewareCheers.. Link to comment Share on other sites More sharing options...
bshoenhair Posted April 8, 2005 Share Posted April 8, 2005 From the help file Not all servers will correctly give the filesize, especially when using a proxy server. I have experienced that the odds are against you if you use the comparison of "$sizeweb <> $sizehome". I use is a 1KB differencial ratio which seems to work better due to server inconsistency filesize that InetGetSize returns. Link to comment Share on other sites More sharing options...
Developers Jos Posted April 8, 2005 Developers Share Posted April 8, 2005 http://scintilla.sourceforge.net/SciTEDoc.html - SciTE - AutoIt Editor<{POST_SNAPBACK}>This is the link to the SciTE WebSite, but when you are looking for the special installer for SciTE4AutoIt3 containing all the extra settings and utilities its better to check : http://www.autoitscript.com/autoit3/scite/ SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Xander Posted April 9, 2005 Author Share Posted April 9, 2005 (edited) From the help fileNot all servers will correctly give the filesize, especially when using a proxy server.I have experienced that the odds are against you if you use the comparison of "$sizeweb <> $sizehome". I use is a 1KB differencial ratio which seems to work better due to server inconsistency filesize that InetGetSize returns.<{POST_SNAPBACK}>Nice idea. How would you script that?Busysignal, thanks for the ideas. In context of the thread, I was thinking of programs that get used regularly and updated often. Edited April 9, 2005 by Xander Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now