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 


varibles question
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
tim6389
Professional Member
Professional Member


Joined: 01 Aug 2002
Posts: 790

PostPosted: Thu Nov 21, 2002 2:00 am    Post subject: varibles question Reply with quote

i have alot of varibles in my script...is it best to uses as less varibles as i can?

i have also notice when using alot of varibles the script runs slower or i'am just seeing things here? Sad

btw what i mean by varibles is this

%%whatever = whatever

some code i have seen you can't get aorund varibles meaning you have to uses them cuase of how the script is beening used.
Back to top
View user's profile Send private message
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Thu Nov 21, 2002 2:42 am    Post subject: Reply with quote

A variable is stored in memory, and of course you want to use as little memory as possible. Also the more variables you have to read and write the longer your program will take.
In some cases you can reuse a variable, such as if you have 3 pieces of code that all count something at different times, you can use the same variable to hold the count. Like:
%x = 0
repeat
%x = @SUCC(%x)
until @EQUAL(%x,5)

You can use %x in other loops also instead of adding a new variable for each loop.
So basically, yes use as few as possible, but of course some programs need 100+ variables.

_________________
-Sheep
My pockets hurt...
Back to top
View user's profile Send private message Send e-mail
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Thu Nov 21, 2002 2:45 am    Post subject: Reply with quote

The number of variables shouldn't be a problem (as long
as you don't go over the limit for your VDS version), although
clearing them when you aren't going to use them again
(or no longer need the data they contain) will free up some
memory. You can empty vars like this:

%%myvar = ""

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Thu Nov 21, 2002 2:48 am    Post subject: Reply with quote

OOPS... Sorry Sheep, your post wasn't there when I
started mine... Embarassed

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Thu Nov 21, 2002 3:00 am    Post subject: Reply with quote

I didn't think to mention clearing 'em Smile
_________________
-Sheep
My pockets hurt...
Back to top
View user's profile Send private message Send e-mail
tim6389
Professional Member
Professional Member


Joined: 01 Aug 2002
Posts: 790

PostPosted: Thu Nov 21, 2002 3:51 am    Post subject: OHHHHH Reply with quote

ohhh you can clear them...hummmm i will have to play with that next


thanks

guys
Back to top
View user's profile Send private message
tim6389
Professional Member
Professional Member


Joined: 01 Aug 2002
Posts: 790

PostPosted: Thu Nov 21, 2002 3:58 am    Post subject: hummm Reply with quote

so if you have a variblem that is used only once in your script like in the begining stop you still clear it?


thanks
Back to top
View user's profile Send private message
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Thu Nov 21, 2002 4:15 am    Post subject: Reply with quote

I usually don't because I'm too lazy..but yes you can.
_________________
-Sheep
My pockets hurt...
Back to top
View user's profile Send private message Send e-mail
tim6389
Professional Member
Professional Member


Joined: 01 Aug 2002
Posts: 790

PostPosted: Thu Nov 21, 2002 5:23 am    Post subject: so Reply with quote

any varible that is used SHOULD be clear no mater if its used once or a 100 times right?


thanks
Back to top
View user's profile Send private message
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Thu Nov 21, 2002 5:31 am    Post subject: Reply with quote

Variables are cleared automatically when your program is closed. If you are going to clear any at all, I would clear variables that have been accessed and won't be again.
_________________
-Sheep
My pockets hurt...
Back to top
View user's profile Send private message Send e-mail
tim6389
Professional Member
Professional Member


Joined: 01 Aug 2002
Posts: 790

PostPosted: Thu Nov 21, 2002 7:21 am    Post subject: ok Reply with quote

ok thanks
Back to top
View user's profile Send private message
Skit3000
Admin Team


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

PostPosted: Thu Nov 21, 2002 8:55 am    Post subject: Reply with quote

If the maximum number of variables is 100, and I have used 75 of them, and I empty them, can then use 100 other variables??? I never used so much variables, but it is handy to know...
_________________
[ 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
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Thu Nov 21, 2002 7:32 pm    Post subject: Reply with quote

I honestly don't know, but VDS probably keeps track of them when they are created. I actually am not even sure that setting a variable to = "" will clear it's space out of memory, just what is in the space.
I definetly could be wrong, but I believe that a space is reserved for a variable in memory once it is defined and no matter what the variable holds, that space isn't accessible to other programs. That means that you are still using the same amount memory filled or empty. I would think someone else will know more about this, but I believe that's how it is in other languages.

Also just so there is no confusion, I mentioned 100 variables earlier just as an example, VDS's limit is 256.

_________________
-Sheep
My pockets hurt...
Back to top
View user's profile Send private message Send e-mail
tim6389
Professional Member
Professional Member


Joined: 01 Aug 2002
Posts: 790

PostPosted: Thu Nov 21, 2002 8:04 pm    Post subject: hummm Reply with quote

humm so if that is the case there is really no need to clear it...cuase IF it still uses the memory to store the "blank" varible then you won't be saving on anything
Back to top
View user's profile Send private message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Thu Nov 21, 2002 8:12 pm    Post subject: Reply with quote

No, it still frees up memory when you clear it. The
amount will depend on what you have in the var.

You can put a whole text file in a var... Wink

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Goto page 1, 2, 3  Next
Page 1 of 3

 
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