AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

VERSION EXISTING<>VERSION ACTUAL

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
garry



Joined: 19 Apr 2005
Posts: 1030
Location: switzerland

PostPosted: Wed Jun 22, 2005 9:28 am    Post subject: VERSION EXISTING<>VERSION ACTUAL Reply with quote

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
View user's profile Send private message
toralf



Joined: 31 Jan 2005
Posts: 3842
Location: Bremen, Germany

PostPosted: Wed Jun 22, 2005 2:44 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
garry



Joined: 19 Apr 2005
Posts: 1030
Location: switzerland

PostPosted: Thu Jun 23, 2005 7:17 am    Post subject: Reply with quote

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
View user's profile Send private message
toralf



Joined: 31 Jan 2005
Posts: 3842
Location: Bremen, Germany

PostPosted: Thu Jun 23, 2005 7:34 am    Post subject: Reply with quote

Thanks for pointing the bugs out, I have updated the my above post.
_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Guest






PostPosted: Thu Jun 23, 2005 7:38 am    Post subject: Reply with quote

thanks toralf, check again for:
If ( Bx > %Ax% )
Back to top
toralf



Joined: 31 Jan 2005
Posts: 3842
Location: Bremen, Germany

PostPosted: Thu Jun 23, 2005 7:41 am    Post subject: Reply with quote

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
Code:
If Bx > %Ax%

_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
garry



Joined: 19 Apr 2005
Posts: 1030
Location: switzerland

PostPosted: Thu Jun 23, 2005 7:46 am    Post subject: Reply with quote

sorry toralf, it's correct, you're right..
Back to top
View user's profile Send private message
toralf



Joined: 31 Jan 2005
Posts: 3842
Location: Bremen, Germany

PostPosted: Thu Jun 23, 2005 7:52 am    Post subject: Reply with quote

I changed (shortened) the code again. :9
_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
garry



Joined: 19 Apr 2005
Posts: 1030
Location: switzerland

PostPosted: Thu Jun 23, 2005 9:09 am    Post subject: Reply with quote

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
View user's profile Send private message
toralf



Joined: 31 Jan 2005
Posts: 3842
Location: Bremen, Germany

PostPosted: Thu Jun 23, 2005 9:30 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group