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 


Please help with my code

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


Joined: 02 May 2003
Posts: 2

PostPosted: Wed May 07, 2003 11:50 am    Post subject: Please help with my code Reply with quote

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
View user's profile Send private message Send e-mail
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Wed May 07, 2003 12:43 pm    Post subject: Reply with quote

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
View user's profile Send private message
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Wed May 07, 2003 1:02 pm    Post subject: Reply with quote

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... Smile

_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
kevinandsonya
Newbie


Joined: 02 May 2003
Posts: 2

PostPosted: Wed May 07, 2003 1:04 pm    Post subject: Reply with quote

the "@" in front of the greater worked, can't belive I missed that... thanks for the help

Kevin
Back to top
View user's profile Send private message Send e-mail
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Wed May 07, 2003 1:06 pm    Post subject: Reply with quote

Kevin,
Your welcome... Have fun with VDS Very Happy

_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Wed May 07, 2003 1:16 pm    Post subject: Reply with quote

I can't believe I've misted it too... Crying or Very sad
_________________
[ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial!
Back to top
View user's profile Send private message
Aslan
Valued Contributor
Valued Contributor


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

PostPosted: Wed May 07, 2003 5:22 pm    Post subject: Reply with quote

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 Very Happy
Back to top
View user's profile Send private message Send e-mail
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Wed May 07, 2003 7:01 pm    Post subject: Reply with quote

Skit3000 wrote:
I can't believe I've misted it too... Crying or Very sad


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
View user's profile Send private message Visit poster's website
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Thu May 08, 2003 7:52 am    Post subject: Reply with quote

If you use the [code] tag like FreezingFire mentioned, other people can see your syntax too. That way mistakes like missing else/ends can be solved faster.... Wink
_________________
[ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial!
Back to top
View user's profile Send private message
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Thu May 08, 2003 12:33 pm    Post subject: Reply with quote

Sorry Kevin,
Some people are so spoiled here on the forum Wink Laughing 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
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Thu May 08, 2003 7:12 pm    Post subject: Reply with quote

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. Smile

(I added the code tag to the first post for you)

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
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