 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
garry
Joined: 19 Apr 2005 Posts: 1030 Location: switzerland
|
Posted: Wed Jun 22, 2005 9:28 am Post subject: VERSION EXISTING<>VERSION ACTUAL |
|
|
Control existing version with actual version, when <> start http://www.autohotkey.com/download
| Code: | ;--srchforvers.ahk 2005-06-22 garry --------
;--start http://www.autohotkey.com/download when existing version<>actual version
F1=%A_ScriptDir%\AHKURL.TXT
A=%A_AHKVERSION%
URLDownloadToFile,http://www.autohotkey.com,%F1%
I=0
Loop
{
I+=1
FileReadLine, line, %F1%, %i%
if ErrorLevel <> 0
exitApp
IfInString,line,The latest version is
{
;<p>The latest version is 1.0.35.16 (rele
stringmid,BA,LINE,25,16
GOTO A2
}
}
A2:
filedelete,%F1%
;search only for digit and point
B1=%BA% ;no more space before string
I=0
loop,parse,B1,`
{
Transform,B2,ASC,%A_LOOPFIELD%
I+=1
if B2<46
GOTO A3
if B2>57
GOTO A3
}
A3:
stringmid,B,B1,1,I-1
msgbox,Your existing version is=%A%, Actual version is=%B%
if A<>%B%
{
run,http://www.autohotkey.com/download
ExitApp
}
else
{
ExitApp
}
|
Last edited by garry on Wed Jun 22, 2005 5:08 pm; edited 1 time in total |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3842 Location: Bremen, Germany
|
Posted: Wed Jun 22, 2005 2:44 pm Post subject: |
|
|
Hi Garry,
Thanks for the script. As I looked at your code, I couldn't resist to play with it myself. So here is what I made of it. | Code: | F1=AHKURL.TXT
URLDownloadToFile,http://www.autohotkey.com,%F1%
Loop,Read,%F1%
IfInString,A_LoopReadLine,The latest version is
{
stringmid,BA,A_LoopReadLine,25,17 ;get version, max. 999.999.999.999
Break
}
FileDelete, %F1% ;remove file form disc
BB=%BA% ;remove leading space
If not BB
ExitApp ;exit, if nothing found
StringSplit, B, BB, %A_Space% ; split with spaces
StringSplit, BA, B1, . ; use only first part of current available version and split at dots
A=%A_AHKVERSION% ; get installed version
StringSplit, AA, A, . ; split installed version at dots
Loop, %AA0% ; create unique number for both versions, max. verion 999.999.999.999 leads to 999999999999
{
AA := AA%A_Index%
BA := BA%A_Index%
Ax += AA * 1000 ** ( 4 - A_Index )
Bx += BA * 1000 ** ( 4 - A_Index )
}
If ( Bx > Ax )
{
msgbox,Your installed version is=%A%`n Current available version is=%B1%
run,http://www.autohotkey.com/download
}
else
msgbox,Your installed version is equal to the available version: %B1% |
_________________ Ciao
toralf 
Last edited by toralf on Thu Jun 23, 2005 7:53 am; edited 3 times in total |
|
| Back to top |
|
 |
garry
Joined: 19 Apr 2005 Posts: 1030 Location: switzerland
|
Posted: Thu Jun 23, 2005 7:17 am Post subject: |
|
|
thank you toralf with your idea with stringsplit
I didn't realise , how a version number is constructed, just read a string lenght
sometimes disturb me I don't see the version from a program, made a small script with filegetversion
I tried, didn't work, can you check follow lines:
StringSplit, B, BB, %A_Space% ; split with spaces
If ( Bx > %Ax% )
{
msgbox,...
regards, garry |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3842 Location: Bremen, Germany
|
Posted: Thu Jun 23, 2005 7:34 am Post subject: |
|
|
Thanks for pointing the bugs out, I have updated the my above post. _________________ Ciao
toralf  |
|
| Back to top |
|
 |
Guest
|
Posted: Thu Jun 23, 2005 7:38 am Post subject: |
|
|
thanks toralf, check again for:
If ( Bx > %Ax% ) |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3842 Location: Bremen, Germany
|
Posted: Thu Jun 23, 2005 7:41 am Post subject: |
|
|
Why should that be a problem?
Isn't it correct as it is?
I think with () I do not have to use the %%
only without () I have to write
_________________ Ciao
toralf  |
|
| Back to top |
|
 |
garry
Joined: 19 Apr 2005 Posts: 1030 Location: switzerland
|
Posted: Thu Jun 23, 2005 7:46 am Post subject: |
|
|
| sorry toralf, it's correct, you're right.. |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3842 Location: Bremen, Germany
|
Posted: Thu Jun 23, 2005 7:52 am Post subject: |
|
|
I changed (shortened) the code again. :9 _________________ Ciao
toralf  |
|
| Back to top |
|
 |
garry
Joined: 19 Apr 2005 Posts: 1030 Location: switzerland
|
Posted: Thu Jun 23, 2005 9:09 am Post subject: |
|
|
hello toralf
thank you, works fine
what is the function ** ?
is it possible to write the file to the memory ? (not write to Harddisk) |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3842 Location: Bremen, Germany
|
Posted: Thu Jun 23, 2005 9:30 am Post subject: |
|
|
Hi Garry,
1) ** = power (look for "math" in manual)
2) get file to memory doesn't work, since URLDownloadToFile does what its name states. :) _________________ Ciao
toralf  |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|