Go Back   Winamp Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 19th May 2005, 09:29   #1
MichaelFlya
Member
 
MichaelFlya's Avatar
 
Join Date: May 2005
Location: U.S.A.
Posts: 91
Installer Checks for update using XML

How do I use NSIS to Check for an Update using a XML File?
code:

<?xml version="1.0" encoding="ISO-8859-1" ?>
- <ProgramName>
<version>5.405</version>
</ProgramName>




Lets just say I am Checking something that is Version 5.403
And I use the XML file above Located at a URL Link. It Tells
the Installer that the Most Recent Version is Higher than the
Version Being Installed...

How would I go about this?

-MichaelFlya-
MichaelFlya is offline   Reply With Quote
Old 19th May 2005, 13:40   #2
Joel
Debian user
(Forum King)
 
Joel's Avatar
 
Join Date: Jan 2003
Location: Arch land
Posts: 4,896
At this moment there isn't a *official* XML parser plugin for nsis, here, here, are some un-official plugins.

Search the forum and you find other ways to parse a XML, although if your tree only has version as element, try a loop until you find it.


* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux w/ xfce4.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Debian unstable w/ xfce4.
Joel is offline   Reply With Quote
Old 19th May 2005, 16:45   #3
MichaelFlya
Member
 
MichaelFlya's Avatar
 
Join Date: May 2005
Location: U.S.A.
Posts: 91
Thanks Joel,

Ok to start off how do I call your XML.dll Properly to
Parse it on Node (Version) And Ask if What is Under
the Node is Greater than a Given Number, In this Case
Greater than 5.403 is 5.405, Then Take Action one
way or the other depending on if it ends up Greater or
Lesser.

Lets start at a Line like this... Unless otherwise.

code:

Parse:
XML::TextElementFromNode ${XMLFILE}"ProgramName" "Version"



---
Possibly if OldValue<NewValue Activate "FunctionName"
Other wise Some other Function Gets Activated. Might be
A Type of Fork in the Road for me to Take an Action. Not
that any of my Examples mean anything in the way that
you do it for XML.dll.
-------



I had Read those Links Already actually, I had been
Searching for a while and finally Decided to post ...

-MichaelFlya-

Last edited by MichaelFlya; 19th May 2005 at 17:30.
MichaelFlya is offline   Reply With Quote
Old 19th May 2005, 19:14   #4
MichaelFlya
Member
 
MichaelFlya's Avatar
 
Join Date: May 2005
Location: U.S.A.
Posts: 91
Ok well If it Can't than Perhaps Maybe It can be Done With
the one Called nsXML.dll. How would that be Done? And if not
than Where can I get the thing I am Looking for?

-MichaelFlya-
MichaelFlya is offline   Reply With Quote
Old 19th May 2005, 20:09   #5
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
I used this to get text between two tags in an HTML file, so it should work here too:
http://nsis.sourceforge.net/archive/...ances=0,11,311

-Stu

Need an installer? http://www.afrowsoft.co.uk
Afrow UK is offline   Reply With Quote
Old 19th May 2005, 21:06   #6
MichaelFlya
Member
 
MichaelFlya's Avatar
 
Join Date: May 2005
Location: U.S.A.
Posts: 91
Afrow Uk, (About your Link)

I Have no idea what to do with this... What to change I
mean. Also When I Get it Going to where it Grabs in this
Case in Between <version> & </version> Which Should
return 5.405, How would I say 5.403 is Less than The
text Returned.

Than say if Text Returned is Greater than
5.403 (Call FunctionNameUPDATE) If 5.403
is just Equal to the text Returned it will
than (Call FunctionNameNOUPDATE)

-MichaelFlya-
MichaelFlya is offline   Reply With Quote
Old 19th May 2005, 21:33   #7
MichaelFlya
Member
 
MichaelFlya's Avatar
 
Join Date: May 2005
Location: U.S.A.
Posts: 91
Please Help me Get the Text... And if you want, Also
Please Add how to Check Version Number by Less and
Greater. That would be the next Question Anyway lol.

Attached a Script.

Thanks !!!

-MichaelFlya-
Attached Files
File Type: nsi gettext.nsi (1.6 KB, 58 views)

Last edited by MichaelFlya; 19th May 2005 at 21:56.
MichaelFlya is offline   Reply With Quote
Old 19th May 2005, 23:58   #8
MichaelFlya
Member
 
MichaelFlya's Avatar
 
Join Date: May 2005
Location: U.S.A.
Posts: 91
Here is the XML to go along with the NSI Script.

-MichaelFlya-
Attached Files
File Type: xml currentversion.xml (102 Bytes, 74 views)
MichaelFlya is offline   Reply With Quote
Old 20th May 2005, 10:28   #9
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
code:
${GetBetween} "<version>" "</version>" "$INSTDIR\currentversion.xml" "$R0"
${VersionCompare} "$R0" "5.405" "$R0"
StrCmp $R0 0 0 +2
MessageBox MB_OK "Versions equal" IDOK Done
StrCmp $R0 1 0 +2
MessageBox MB_OK "Version one newer" IDOK Done
StrCmp $R0 2 0 +2
MessageBox MB_OK "Version two newer"
Done:



VersionCompare: http://nsis.sourceforge.net/archive/...s=0,11,122,754

Edit: Make sure you put functions code (from archive pages) in the script before you actually use them.

-Stu

Need an installer? http://www.afrowsoft.co.uk
Afrow UK is offline   Reply With Quote
Old 21st May 2005, 07:05   #10
MichaelFlya
Member
 
MichaelFlya's Avatar
 
Join Date: May 2005
Location: U.S.A.
Posts: 91
Thanks Afrow UK, I am Starting to Get somewhere....

I am Still having Problems... I don't know, I have
attached what I made and Theres still a few bugs. It
seems to Never Retrieve The Value of the XML File
Correctly. So I Changed one of the Lines to test it.

Function VersionCompare is Working Fine Using this.

${VersionCompare} "5.405" "5.403" "$R0"

It also I Guess is only Checking the Last two Digits.
All I know is it Makes 5.405 More than 5.403, But if
I change 5.403 to 5.8 it is less than 5.405 For Some
Reason.

What can be done to make it work with all Digits?
Why Isn't it Grabbing the XML Value Correctly?


-MichaelFlya-
Attached Files
File Type: nsi gettext.nsi (3.1 KB, 52 views)
MichaelFlya is offline   Reply With Quote
Old 21st May 2005, 07:25   #11
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 665
Quote:
I change 5.403 to 5.8 it is less than 5.405 For Some
Reason.
code:
${VersionCompare} "5.405" "5.8" "$R0"
;$R0=1

It's correct. Because
code:
${VersionCompare} "5.10" "5.8" "$R0"
;$R0=1

Right comparison (in your case):
code:
${VersionCompare} "5.4.05" "5.8" "$R0"
;$R0=2


Last edited by Instructor; 21st May 2005 at 07:41.
Instructor is offline   Reply With Quote
Old 21st May 2005, 12:01   #12
MichaelFlya
Member
 
MichaelFlya's Avatar
 
Join Date: May 2005
Location: U.S.A.
Posts: 91
I need to add a Decimal every Time after the first Decimal?

When using this Method I must Make my Versions like:
0.0.0.0.0.0.0.0.0.0.0.0.0.0.0


-MichaelFlya-
MichaelFlya is offline   Reply With Quote
Old 21st May 2005, 12:27   #13
MichaelFlya
Member
 
MichaelFlya's Avatar
 
Join Date: May 2005
Location: U.S.A.
Posts: 91
As far as Function GetBetween Goes, Using Detail
Print like this:

code:

DetailPrint "$R0"



It Should Return The Version Number of the XML.
But it turns up Blank. I figure once the Code for
that Function is Working Properly I will get a Result
from the XML. This is what I need to have worked
out at the Moment.

Oh and After Function VersionCompare I see it Is
used to say 1 or 2.

-MichaelFlya-
MichaelFlya is offline   Reply With Quote
Old 21st May 2005, 13:17   #14
MichaelFlya
Member
 
MichaelFlya's Avatar
 
Join Date: May 2005
Location: U.S.A.
Posts: 91
Ahh Something Small I have now Figured it out....

code:

${GetBetween} "<version>" "</version>" ".\currentversion.xml" "$R0"



That helped on Returning the Value Found in XML. I must
have not Set the Install Directory. Instead I set OutFile.


But now For Function VersionCompare. Making the Number in
the XML file 5.1 Instead of 5.405 and Doing this with the Line
of Code:

Code:
code:

${VersionCompare} "$R0" "5.0" "$R0"



Everything works When I change 5.0 in the Script to a
more Higher Version than 5.1 it works as I want. Plus
when I change 5.1 in the XML to what ever. So now I
can Work With this. A good Explanation on why it's
best to do 0.0.0.0.0 Decimals is needed but ok to Use.


Both Afrow Uk And Instructor, All I can say is Thanks !!!!

And Joel When ever I need to Write a XML With the
Installer I am sure those Links will Come in handy,
Thanks !!!!




-MichaelFlya-
MichaelFlya is offline   Reply With Quote
Reply
Go Back   Winamp Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump