| View previous topic :: View next topic |
| Author |
Message |
Aslan Valued Contributor


Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Wed Dec 29, 2004 1:59 am Post subject: Math function help |
|
|
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 |
|
 |
Aslan Valued Contributor


Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Wed Dec 29, 2004 2:10 am Post subject: |
|
|
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 |
|
 |
Aslan Valued Contributor


Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Wed Dec 29, 2004 2:21 am Post subject: |
|
|
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 |
|
 |
Serge Professional Member


Joined: 04 Mar 2002 Posts: 1480 Location: Australia
|
Posted: Wed Dec 29, 2004 8:27 am Post subject: |
|
|
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 |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Wed Dec 29, 2004 1:59 pm Post subject: |
|
|
Yes; because the numbers are non-numeric, they cannot be compared with
the numerical functions. I would go with Serge's idea.  _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
Aslan Valued Contributor


Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Wed Dec 29, 2004 2:21 pm Post subject: |
|
|
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 |
|
 |
Serge Professional Member


Joined: 04 Mar 2002 Posts: 1480 Location: Australia
|
Posted: Fri Dec 31, 2004 12:32 am Post subject: |
|
|
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 |
|
 |
|