forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Math function help

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
Aslan
Valued Contributor
Valued Contributor


Joined: 31 May 2001
Posts: 589
Location: Memphis, TN USA

PostPosted: Wed Dec 29, 2004 1:59 am    Post subject: Math function help Reply with quote

Why does VDS think that 6.00.1.2003110300 is greater than
6.0.1.2003110300?

I realize that @len(6.00.1.2003110300) is greater than @len(6.0.1.2003110300) but, I believe numerically it should be less

Code:

OPTION DECIMALSEP,"."
%%FileVer = 6.00.1.2003110300
%%LocVer = 6.0.1.2003110300
If @equal(%%FileVer,%%LocVer)
         info Equal
        else
         If @greater(%%FileVer,%%LocVer)
          Info Greater Than
         else
          Info Less Than         
         end
         end


Last edited by Aslan on Wed Dec 29, 2004 2:06 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
Aslan
Valued Contributor
Valued Contributor


Joined: 31 May 2001
Posts: 589
Location: Memphis, TN USA

PostPosted: Wed Dec 29, 2004 2:10 am    Post subject: Reply with quote

This is probably a better example

Code:

OPTION DECIMALSEP,"."
%%FileVer = 9.00.1.2003110300
%%LocVer = 11.0.1.2003110300
If @equal(%%FileVer,%%LocVer)
         info Equal
        else
         If @greater(%%FileVer,%%LocVer)
          Info Greater Than
         else
          Info Less Than         
         end
        end
Back to top
View user's profile Send private message Send e-mail
Aslan
Valued Contributor
Valued Contributor


Joined: 31 May 2001
Posts: 589
Location: Memphis, TN USA

PostPosted: Wed Dec 29, 2004 2:21 am    Post subject: Reply with quote

Hmmm...

Seems that the values aren't numeric.

That explains half the problem.

What I'm trying to do is compare file versions to determine if the existing one is newer or older

As shown in the example above that is how the versions are reported.
Back to top
View user's profile Send private message Send e-mail
Serge
Professional Member
Professional Member


Joined: 04 Mar 2002
Posts: 1480
Location: Australia

PostPosted: Wed Dec 29, 2004 8:27 am    Post subject: Reply with quote

why don't you parse the version numbers and then compare each part to determine which is bigger than which

off the top of my head...

Code:
option decimalsep, .
parse "%1;%2;%3;%4", %%version1
parse "%5;%6;%7;%8", %%version2


and then compare each version section

serge

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Wed Dec 29, 2004 1:59 pm    Post subject: Reply with quote

Yes; because the numbers are non-numeric, they cannot be compared with
the numerical functions. I would go with Serge's idea. Smile

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
Aslan
Valued Contributor
Valued Contributor


Joined: 31 May 2001
Posts: 589
Location: Memphis, TN USA

PostPosted: Wed Dec 29, 2004 2:21 pm    Post subject: Reply with quote

Serge wouldn't I need to also to add Option fieldsep, "."?

Code:

  option fieldsep,"."
  option decimalsep, .
  parse "%1;%2;%3;%4", %%version1
  parse "%5;%6;%7;%8", %%version2



I was hoping there was a simpler way but, I guess I'll have to do it the long way.
Back to top
View user's profile Send private message Send e-mail
Serge
Professional Member
Professional Member


Joined: 04 Mar 2002
Posts: 1480
Location: Australia

PostPosted: Fri Dec 31, 2004 12:32 am    Post subject: Reply with quote

hi aslan,

off the top of my head is obviously not so good...you are correct in that you do need to add OPTION FIELDSEP and i don't think that you need OPTION DECIMALSEP (i had meant to type the former, not the latter)

i know it is a pain to have to think of long ways of doing something that seems so simple but 2.3.5 is not a number and hence cannot be treated as a number

on the plus side, you can create a function or command with the code to compare versions so that you only need to write the code once, and invoke the function or command whenever you need to in your code

serge

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group