Click HereClick Here
home features news forums classifieds faqs links search
5153 members 
Amiga Q&A /  Free for All /  Emulation /  Gaming / (Latest Posts)
Login

Nickname

Password

Lost Password?

Don't have an account yet?
Register now!

Support Amigaworld.net
Your support is needed and is appreciated as Amigaworld.net is primarily dependent upon the support of its users.
Donate

Menu
Main sections
» Home
» Features
» News
» Forums
» Classifieds
» Links
» Downloads
Extras
» OS4 Zone
» IRC Network
» AmigaWorld Radio
» Newsfeed
» Top Members
» Amiga Dealers
Information
» About Us
» FAQs
» Advertise
» Polls
» Terms of Service
» Search

IRC Channel
Server: irc.amigaworld.net
Channel: #Amigaworld
Channel Policy and Guidelines

(Uses JAVA Applet and Port 1024)
Visit the Chatroom Website

Who's Online
 17 guest(s) on-line.
 0 member(s) on-line.



You are an anonymous user.
Register Now!
 Drako:  11 mins ago
 amigang:  14 mins ago
 freak:  31 mins ago
 damocles:  38 mins ago
 resle:  44 mins ago
 ggw:  56 mins ago
 Panthro:  1 hr 3 mins ago
 terminills:  1 hr 10 mins ago
 tommysammy:  1 hr 21 mins ago
 Spectre660:  1 hr 40 mins ago

/  Forum Index
   /  Classic Amiga Software
      /  Startup-Sequence if then else version check
Register To Post

PosterThread
sananaman 
Startup-Sequence if then else version check
Posted on 13-May-2012 11:37:53
#1 ]
Regular Member
Joined: 28-Sep-2006
Posts: 215
From: Netherlands

Dear all,

I'm trying to figure out how to check on a version of a library and to do an action on it from the startup-sequence i.e. dos script.

This is what I need (pseudo):


$ver = version >NIL: some.library
if $ver EQ "1.1"
#execute program
endif
if $ver EQ "1.2"
#execute program
endif
if $ver EQ "1.3"
#execute program
endif


I've been playing around with the well known 'if not warn' construction but it doesn't work well. It always assumes that a lower version is also OK if a higher version was found.

For example (does not work):

version >NIL: some.library version=1 revision=1
if not warn
#execute program
else
version >NIL: some.library version=1 revision=2
if not warn
#execute program
else
version >NIL: some.library version=1 revision=2
if not warn
#execute program
endif
endif
endif

The problem with above is that when you have library 2.0 every version check results in OK because version assumes that if you have a newer it also OK if you have an older and it results in an OK.

There must be another better and more clean way..... anyone?

Note:
Ideally it would be nice to capture the version number and put it in an variable and then evaluate the variable.

_________________
AmigaScene.nl

 Status: Offline
Profile     Report this post  
salass00 
Re: Startup-Sequence if then else version check
Posted on 13-May-2012 11:46:46
#2 ]
Elite Member
Joined: 31-Oct-2003
Posts: 2438
From: Finland

@sananaman


version >NIL: some.library version=1 revision=3
if not warn
; we have version 1.3 or newer
else
version >NIL: some.library version=1 revision=2
if not warn
; we have version 1.2
else
version >NIL: some.library version=1 revision=1
if not warn
; we have version 1.1
else
; we have a version older than 1.1
endif
endif
endif

_________________
µA1-C - 750FX 800MHz, 512MB, 20GB HD, DVD-RW, OS4.1
Sam440ep - 440EP 667MHz, 512MB, 700GB HD, DVD-RW, OS4.1

 Status: Offline
Profile     Report this post  
sananaman 
Re: Startup-Sequence if then else version check
Posted on 13-May-2012 12:14:40
#3 ]
Regular Member
Joined: 28-Sep-2006
Posts: 215
From: Netherlands

@salass00

That I tried that already myself and does not work 100% correct.

If let's say I test on version in the code:
- 1.4
- 1.0
- 0.9

But for some reason there is a 1.5 available it will be detected as 1.4.
Or when someone got a 1.3 it will be seen as 1.0.

The version command evaluates 'matching number OR higher'.

That is the whole problem where I bump into, I want to EXACTLY match the number (EQUALS).

Last edited by sananaman on 13-May-2012 at 12:15 PM.

_________________
AmigaScene.nl

 Status: Offline
Profile     Report this post  
Gazelle 
Re: Startup-Sequence if then else version check
Posted on 13-May-2012 13:51:01
#4 ]
Regular Member
Joined: 4-Apr-2005
Posts: 109
From: Austria

@sananaman

You just need more if statements:


version >NIL: some.library version=1 revision=5
if not warn
; we have version 1.5 or newer
else
version >NIL: some.library version=1 revision=4
if not warn
; we have version 1.4
else
version >NIL: some.library version=1 revision=1
if not warn
; we have version 1.1, 1.2 or 1.3
else
version >NIL: some.library version=1 revision=0
if not warn
; we have version 1.0
else
version >NIL: some.library version=0 revision=9
if not warn
; we have version 0.9
else
; we have version 0.8 or older
endif
endif
endif
endif
endif

 Status: Offline
Profile     Report this post  
tbreeden 
Re: Startup-Sequence if then else version check
Posted on 13-May-2012 14:30:23
#5 ]
Member
Joined: 8-Feb-2004
Posts: 99
From: Charlottesville, Virginia, USA

@sananaman
Quote:
Note:
Ideally it would be nice to capture the version number and put it in an variable and then evaluate the variable.


It is not too hard to do such things with ADOS batch using "backtick" and "cut".

eg,

setenv fullver `version file libs:reqtools.library`
setenv fullver `cut "$fullver" word=2`
setenv majorver `cut $fullver w=1 s=.`
setenv minorver `cut $fullver w=2 s=.`
echo $majorver
echo $minorver

Tom

Last edited by tbreeden on 13-May-2012 at 02:31 PM.

 Status: Offline
Profile     Report this post  
salass00 
Re: Startup-Sequence if then else version check
Posted on 13-May-2012 19:04:02
#6 ]
Elite Member
Joined: 31-Oct-2003
Posts: 2438
From: Finland

@sananaman

Don't know how you're testing this but it's worth noting that the version will by default first check for the library in memory before it will check for a file on disk, so if some program has the library loaded in memory and you test just by replacing the file in LIBS: then you might not get the result you expect.

In order to force "version" to get the version information from the file on disk you can use the "file" switch.

_________________
µA1-C - 750FX 800MHz, 512MB, 20GB HD, DVD-RW, OS4.1
Sam440ep - 440EP 667MHz, 512MB, 700GB HD, DVD-RW, OS4.1

 Status: Offline
Profile     Report this post  
salass00 
Re: Startup-Sequence if then else version check
Posted on 13-May-2012 19:07:35
#7 ]
Elite Member
Joined: 31-Oct-2003
Posts: 2438
From: Finland

@Gazelle

That's more or less what I suggested above but he claims that it doesn't work (it should work since it checks for higher version numbers first before lower ones unlike sananaman's version which checks them in the wrong order and doesn't work for obvious reasons).

_________________
µA1-C - 750FX 800MHz, 512MB, 20GB HD, DVD-RW, OS4.1
Sam440ep - 440EP 667MHz, 512MB, 700GB HD, DVD-RW, OS4.1

 Status: Offline
Profile     Report this post  
Xenic 
Re: Startup-Sequence if then else version check
Posted on 14-May-2012 0:35:53
#8 ]
Cult Member
Joined: 2-Feb-2004
Posts: 963
From: Pennsylvania, USA

@sananaman
Quote:
There must be another better and more clean way..... anyone?
Note:
Ideally it would be nice to capture the version number and put it in an variable and then evaluate the variable.

If you want to match exact versions then your pseudo code is close. See if this works:

;AmigaDOS Script
Set library libs:some.library
If EXISTS $library
Set version `Version *>NIL: file $library`
If "$version" EQ "some.library 1.1"
; #execute program
skip done
Endif
If "$version" EQ "some.library 1.2"
; #execute program
skip done
Endif
If "$version" EQ "some.library 1.3"
; #execute program
skip done
Endif
lab done
Unset version
Endif
Unset library


Last edited by Xenic on 14-May-2012 at 07:52 PM.
Last edited by Xenic on 14-May-2012 at 12:39 AM.

_________________
SAM Flex 800MZ with 1GB memory & OS4.1u4

 Status: Offline
Profile     Report this post  
Toaks 
Re: Startup-Sequence if then else version check
Posted on 14-May-2012 7:17:52
#9 ]
Elite Member
Joined: 10-Mar-2003
Posts: 7792
From: amigaguru.com

@tbreeden



_________________
Brand new website... www.amigaguru.com

 Status: Offline
Profile     Report this post  
sananaman 
Re: Startup-Sequence if then else version check
Posted on 27-May-2012 15:52:15
#10 ]
Regular Member
Joined: 28-Sep-2006
Posts: 215
From: Netherlands

@All that helped:
Guys I really would like to thank you all for thinking about solutions the get a nice script.

My personal opinion is that Xenic got the most clean code solution.
Al the others are too much nesting of 'if then else' inside 'if then else'. It doesn't look clean and it's too easy to make a mistakes. But thanks for the thinking work anyway.

@Xenic:
On my system this part doesn't work:

Set version `Version *>NIL: file $library`
(This raises an error messge).

It needs to be:

Set version `Version file $library`

As the result (no matter what it will be) will be placed in the variable 'version' anyway.
I've also changed the 'version' variable in something else to avoid confusion.

And if you only want to evaluate on 'version number' instead of 'some.libary versionnumber' then you might want to use the trick of tbreeden.
Altough I've not tested this in real.

Thanks all....

_________________
AmigaScene.nl

 Status: Offline
Profile     Report this post  

[ home ][ about us ] [ forums ][ classifieds ] [ links ][ news archive ] [ link to us ][ user account ]
Copyright © 2000 - 2011 Amigaworld.net.

Page took 0.089194 seconds to load.