AutoHotkey Community

It is currently May 27th, 2012, 6:38 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: April 14th, 2011, 12:40 pm 
Hi,

I'm having a problem trying to see if two variables are equal, I've googled and searched the forum. I know that using % around the variable will use the value, since If var, value is the correct method of writing a statement. I read 0.0.2 from conf.ini file and checks it with update.ini

I'm trying to check if there's a newer version of some files available, this is checked in two IF-statements. But eventhough it's up-to-date and it tries to check if 0.0.2 equals 0.0.2 it continues to update the files?

Code:
updatecheck:
UrlDownloadToFile, http://www.XXXXXX.com/update/update.ini, update.ini
IniRead, tempupdateversion, update.ini, updatecheck, updateversion
updateversion = tempupdateversion
version = tempversion
If version = updateversion && ErrorLevel = 0
{
SB_SetText("Build " . %version%)
SB_SetIcon("updated.ico")
}
else if updateversion != version &&  ErrorLevel = 0
{
SB_SetIcon("warning.ico")
SB_SetText("Updating to " . %updateversion%)
TrayTip, Program, Updating, 10, 1
Sleep 4000
Gosub, update
}
return

update:
IniRead, tempupdateversion, update.ini, updatecheck, updateversion
updateversion = %tempupdateversion%
version = %tempversion%
IniRead, currentProgramURL, conf.ini, Configuration, ProgramURL
IniRead, updateProgramURL, update.ini, update, Program
IniRead, updateConfURL, update.ini, update, Conf
UrlDownloadToFile, updateProgramURL, TankBot.exe
UrlDownloadToFile, updateConfURL, conf.ini
iniWrite, %currentProgramURL%, conf.ini, Configuration, ProgramURL
iniWrite, %updateversion%, conf.ini, Configuration, version
SB_SetText("Build " . updateversion)
SB_SetIcon("updated.ico")


The code is pretty dirty after all the debugging and fixing - I hope you can help me out here.

Thanks in advance,

C


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 14th, 2011, 12:48 pm 
Offline

Joined: February 22nd, 2009, 5:37 am
Posts: 52
Location: Banten, Indonesia
You should use parentheses to If statement. Hope this helps.

Code:
updatecheck:
UrlDownloadToFile, http://www.XXXXXX.com/update/update.ini, update.ini
IniRead, tempupdateversion, update.ini, updatecheck, updateversion
updateversion = tempupdateversion
version = tempversion
If(version = updateversion AND ErrorLevel = 0)
{
SB_SetText("Build " . %version%)
SB_SetIcon("updated.ico")
}
else if(updateversion <> version AND ErrorLevel = 0)
{
SB_SetIcon("warning.ico")
SB_SetText("Updating to " . %updateversion%)
TrayTip, Program, Updating, 10, 1
Sleep 4000
Gosub, update
}
return

update:
IniRead, tempupdateversion, update.ini, updatecheck, updateversion
updateversion = %tempupdateversion%
version = %tempversion%
IniRead, currentProgramURL, conf.ini, Configuration, ProgramURL
IniRead, updateProgramURL, update.ini, update, Program
IniRead, updateConfURL, update.ini, update, Conf
UrlDownloadToFile, updateProgramURL, TankBot.exe
UrlDownloadToFile, updateConfURL, conf.ini
iniWrite, %currentProgramURL%, conf.ini, Configuration, ProgramURL
iniWrite, %updateversion%, conf.ini, Configuration, version
SB_SetText("Build " . updateversion)
SB_SetIcon("updated.ico")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 14th, 2011, 1:03 pm 
Thanks! I've tried the code and I've cleaned it up a bit.

The code looks like
Code:
updatecheck:
UrlDownloadToFile, http://www.XXXXX.com/update/update.ini, update.ini
IniRead, updateversion, update.ini, updatecheck, updateversion

If(version = updateversion AND ErrorLevel = 0)
{
SB_SetText("Build " . %version%)
SB_SetIcon("updated.ico")
}
else if(updateversion <> version AND ErrorLevel = 0)
{
SB_SetIcon("warning.ico")
SB_SetText("Updating to " . %updateversion%)
TrayTip, Program, Updating, 10, 1
Sleep 4000
Gosub, update
}
return

update:
IniRead, updateversion, update.ini, updatecheck, updateversion
IniRead, currentProgramURL, conf.ini, Configuration, ProgramURL
IniRead, updateProgramURL, update.ini, update, Program
IniRead, updateConfURL, update.ini, update, Conf
UrlDownloadToFile, updateProgramURL, TankBot.exe
UrlDownloadToFile, updateConfURL, conf.ini
iniWrite, %currentProgramURL%, conf.ini, Configuration, ProgramURL
iniWrite, %updateversion%, conf.ini, Configuration, version
SB_SetText("Build " . updateversion)
SB_SetIcon("updated.ico")
return


Though it returns
"Error: The following variable contains an illegal character

024: SB_SetText("Build " . %version%)"


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 14th, 2011, 1:12 pm 
The illegal character is "0.0.2"


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 14th, 2011, 1:58 pm 
Offline

Joined: October 9th, 2006, 8:19 pm
Posts: 236
Location: Finland
Percent signs shouldn't normally be used in function's parameters.

(I assume the error message is:
The following variable name contains an illegal character:)

_________________
Pekka Vartto


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 14th, 2011, 4:27 pm 
Thanks guys, works like a charm now!


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: batto, Bing [Bot], Exabot [Bot], JSLover and 58 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group