| View previous topic :: View next topic |
| Author |
Message |
kevinandsonya Newbie
Joined: 02 May 2003 Posts: 2
|
Posted: Wed May 07, 2003 11:50 am Post subject: Please help with my code |
|
|
Hi Everyone,
What I'm trying to do is compare the number within two text files. On my C drive I have a file named version.txt with a 9 in it. On my D Drive I have a file named version.txt with a 10 in it. Each time I run my code I get 9 is newer than 10. Since 10 is greater than 9, I should be seeing the info box that says 9 is older than 10, but I always get 9 is newer than 10.
| Code: | LIST CREATE, 1
LIST LOADFILE,1,c:\version.txt
LIST SEEK,1
%%version = @ITEM(1)
list create, 2
list loadfile,2,d:\version.txt
list seek,2
%%newversion = @item(2)
rem info the newversion is %%newversion
if greater(%%version,%%newversion)
info %%version is newer than %%newversion
end
else
info %%version is older than %%newversion
end |
Thanks for the help
[ Code tag added by moderator ] |
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Wed May 07, 2003 12:43 pm Post subject: |
|
|
Try this:
| Code: | LIST CREATE, 1
LIST LOADFILE,1,c:\version.txt
LIST SEEK,1
%%version = @ITEM(1)
list create, 2
list loadfile,2,d:\version.txt
rem Changed next line....
list seek,1
%%newversion = @item(2)
rem info the newversion is %%newversion
if greater(%%version,%%newversion)
info %%version is newer than %%newversion
end
else
info %%version is older than %%newversion
end |
_________________ [ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial! |
|
| Back to top |
|
 |
vdsalchemist Admin Team

Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Wed May 07, 2003 1:02 pm Post subject: |
|
|
Hi kevinandsonya,
You forgot to put an '@' infront of the greater(%%version,%%newversion). Also your 'if' block needs some work it should read like below.
| Code: |
if @greater(%%version,%%newversion)
info %%version is newer than %%newversion
else
info %%version is older than %%newversion
end
|
You don't need the extra 'end' before the 'else'...
BTW Welcome to VDSWorld.com...  _________________ Home of
Give VDS a new purpose!
 |
|
| Back to top |
|
 |
kevinandsonya Newbie
Joined: 02 May 2003 Posts: 2
|
Posted: Wed May 07, 2003 1:04 pm Post subject: |
|
|
the "@" in front of the greater worked, can't belive I missed that... thanks for the help
Kevin |
|
| Back to top |
|
 |
vdsalchemist Admin Team

Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Wed May 07, 2003 1:06 pm Post subject: |
|
|
Kevin,
Your welcome... Have fun with VDS  _________________ Home of
Give VDS a new purpose!
 |
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
|
| Back to top |
|
 |
Aslan Valued Contributor


Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Wed May 07, 2003 5:22 pm Post subject: |
|
|
You also forgot to tell the list what index to seek (incase you eventually create more lines in each textfile)
List seek,1,?
e.g.
List seek,1,1
List seek,2,1
"0" is where a list will default to when first loaded, which is probably why it worked anyway. If your numbers were on different lines in the file it would have failed.
WELCOME TO VDSWORLD  |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Wed May 07, 2003 7:01 pm Post subject: |
|
|
| Skit3000 wrote: | I can't believe I've misted it too...  |
It would be easier to read with the [code] tag. Just put this tag around
your code as follows:
[code]info Welcome to VDSWORLD![/code] _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
|
| Back to top |
|
 |
vdsalchemist Admin Team

Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Thu May 08, 2003 12:33 pm Post subject: |
|
|
Sorry Kevin,
Some people are so spoiled here on the forum The code tag highlights your code and brings it out more so they can read it. _________________ Home of
Give VDS a new purpose!
 |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Thu May 08, 2003 7:12 pm Post subject: |
|
|
There used to be a [code:1:] tag but with the forum upgrade that was lost.
However in the future it may be possible to re-implement it.
(I added the code tag to the first post for you) _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
|