| View previous topic :: View next topic |
| Author |
Message |
tim6389 Professional Member


Joined: 01 Aug 2002 Posts: 790
|
Posted: Thu Nov 21, 2002 2:00 am Post subject: varibles question |
|
|
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?
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 |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Thu Nov 21, 2002 2:42 am Post subject: |
|
|
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 |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Thu Nov 21, 2002 2:45 am Post subject: |
|
|
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  _________________ 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 |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Thu Nov 21, 2002 2:48 am Post subject: |
|
|
OOPS... Sorry Sheep, your post wasn't there when I
started mine...
Cheers, Mac  _________________ 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 |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Thu Nov 21, 2002 3:00 am Post subject: |
|
|
I didn't think to mention clearing 'em  _________________ -Sheep
My pockets hurt... |
|
| Back to top |
|
 |
tim6389 Professional Member


Joined: 01 Aug 2002 Posts: 790
|
Posted: Thu Nov 21, 2002 3:51 am Post subject: OHHHHH |
|
|
ohhh you can clear them...hummmm i will have to play with that next
thanks
guys |
|
| Back to top |
|
 |
tim6389 Professional Member


Joined: 01 Aug 2002 Posts: 790
|
Posted: Thu Nov 21, 2002 3:58 am Post subject: hummm |
|
|
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 |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Thu Nov 21, 2002 4:15 am Post subject: |
|
|
I usually don't because I'm too lazy..but yes you can. _________________ -Sheep
My pockets hurt... |
|
| Back to top |
|
 |
tim6389 Professional Member


Joined: 01 Aug 2002 Posts: 790
|
Posted: Thu Nov 21, 2002 5:23 am Post subject: so |
|
|
any varible that is used SHOULD be clear no mater if its used once or a 100 times right?
thanks |
|
| Back to top |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Thu Nov 21, 2002 5:31 am Post subject: |
|
|
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 |
|
 |
tim6389 Professional Member


Joined: 01 Aug 2002 Posts: 790
|
Posted: Thu Nov 21, 2002 7:21 am Post subject: ok |
|
|
| ok thanks |
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
|
| Back to top |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Thu Nov 21, 2002 7:32 pm Post subject: |
|
|
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 |
|
 |
tim6389 Professional Member


Joined: 01 Aug 2002 Posts: 790
|
Posted: Thu Nov 21, 2002 8:04 pm Post subject: hummm |
|
|
| 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 |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Thu Nov 21, 2002 8:12 pm Post subject: |
|
|
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...
Cheers, Mac  _________________ 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 |
|
 |
|